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:)
總結
以上是生活随笔為你收集整理的python一个函数调用另一个函数的返回值_在另一个函数中使用返回值的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php强大的函数,PHP中一些功能强大却
- 下一篇: python三维数组切片_【NumPy学