我想獲得某種確認上傳是成功的,我有我的方法定義類似於以下內容。但是全局變量的值沒有變化。請幫助python如何更改全局變量
global upload_confirm
upload_confirm = False
def confirm_upload():
upload_confirm = True
def start_new_upload():
confirm_upload()
while (upload_confirm != True):
print "waiting for upload to be true"
time.sleep(5)
if (upload_confirm == True):
print "start Upload"
start_new_upload()
如果我只想讀一個全局變量,我可以跳過每個函數開始時的'global'聲明嗎? – SomethingSomething 2014-09-28 14:20:45
是的,你可以做到。 – 2014-09-28 14:21:24