以下打印出“无”而不是“无论什么”。我不明白为什么。
dirr = None
def method():
global dirr # you have to declare that you'll use global variable 'dirr'
dirr = "whatever"
print `dirr`
你应该一次叫'方法'。
dirr = None
def method():
global dirr # you have to declare that you'll use global variable 'dirr'
dirr = "whatever"
method()
print (dirr)
结果是:
whatever