1
我試圖在功能edl_flashing
全局變量edl_loading
的值更改爲True
,不知它不工作?任何人都可以幫助理解爲什麼print edl_loading
打印False
調用edl_flashing
後,我將值改爲True
如何通過函數調用設置全局變量?
def edl_flashing():
edl_loading = True
print edl_loading
def main():
global edl_loading
edl_loading = False
print edl_loading
edl_flashing()
print edl_loading #Why this prints as False
if __name__ == '__main__':
main()
OUTPUT: -
False
True
False
'edl_loading'在'edl_flashing'是局部的功能。 – Pythonista