以下内容打印出“无”而不是“任何内容”。我不明白为什么。
dirr = None
def method():
global dirr # you have to declare that you'll use global variable 'dirr'
dirr = "whatever"
print `dirr`
答案 0 :(得分:1)
您应该一次调用“方法”。
dirr = None
def method():
global dirr # you have to declare that you'll use global variable 'dirr'
dirr = "whatever"
method()
print (dirr)
结果是:
whatever