1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > python一个函数调用另一个函数的返回值_在另一个函数中使用返回值

python一个函数调用另一个函数的返回值_在另一个函数中使用返回值

时间:2023-11-20 11:10:29

相关推荐

python一个函数调用另一个函数的返回值_在另一个函数中使用返回值

所以我认为当你调用check_channel_number函数时,user_channel_number是在那里定义的,所以当你调用delete_events函数时,它已经超出了范围,也许这样会有帮助?user_channel_number = check_channel_number()

delete_events()

我可能也会将用户频道号作为delete函数的输入,所以它会变成这样:(其中ucn是user_channel_number)def delete_events(self, ucn):

if ucn == True:

print 'The program number is correct and will be deleted'

# action = 'DeleteEvent'

menu_action = 'all'

book = 'RECYC:687869882'

arg_list = [('C:\\Users\\yke01\\Documents\\StormTest\\Scripts\\Completed'

'\\Utils\\UPNP_Client_Cmd_Line.py')]

arg_list.append(' --action=')

arg_list.append(action)

arg_list.append(' --ip=')

arg_list.append('10.10.8.89')

arg_list.append(' --objectId=')

arg_list.append(book)

subprocess.call(["python", arg_list])

print 'The program deleted successfully'

我还将“return”程序号更改为print语句,因为我感觉该返回将在运行其他代码行之前结束函数

所以代码可能会变成:user_channel_number = check_channel_number()

delete_events(user_channel_number)

编辑:

刚刚注意到你的函数看起来是类的一部分

在这种情况下,您可以:self.ucn = self.check_channel_number()

self.delete_events(self.ucn)

(或者如果不想将用户频道号传递到函数中,可以将if user_channel_number:更改为if self. user_channel_number:)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。