0
这里是一个脚本的提取物我写:为什么全局变量被认为是“禁忌”语法?
succ_count = 0
def run_copy():
shutil.copy(file, 'W://20' + year + '/' + foldername + '/')
global succ_count
succ_count += 1
我的一位同事说,使用全局变量这里是坏的。
我可以看到它是不方便的,因为我必须在使用global succ_count
之前递增1。
但为什么全局使用认为编程不好?
道歉,如果这是一个非常明显的问题,我对Python相对陌生,并试图尽可能多地理解事物。
http://stackoverflow.com/questions/19158339/python-why-are-global-variables-vil – 2014-09-11 09:37:55