Помогите разобраться с вот этим кодом
mport os, sys, shutil def copytree(src, dst): for file in os.listdir(src): pathSrc = os.path.join(src,file) pathDst = os.path.join(dst,file) if os.path.isdir(pathSrc): if not os.path.exists(pathDst): os.mkdir(pathDst) copytree(pathSrc, pathDst,) else: shutil.copy2(pathSrc, pathDst) printProgress(i, l, prefix = 'Progress:', suffix = 'Complete', barLength = 50) i+=1 def printProgress (iteration, total, prefix = '', suffix = '', decimals = 2, barLength = 100): filledLength = int(round(barLength * iteration / float(total))) percents = round(100.00 * (iteration / float(total)), decimals) bar = '█' * filledLength + '-' * (barLength - filledLength) sys.stdout.write('\r%s |%s| %s%s %s' % (prefix, bar, percents, '%', suffix)), sys.stdout.flush() if iteration == total: sys.stdout.write('\n') sys.stdout.flush() items = list(range(0, 100)) l = len(items) i = 0 src = 'E:\\temp\\SampleHTML' dst = 'E:\\temp\\TestMkDir' copytree(src,dst)
C:\Users\>python E:\temp\test.py Traceback (most recent call last): File "E:\temp\test.py", line 42, in <module> copytree(src,dst) File "E:\temp\test.py", line 4, in copytree print(i) UnboundLocalError: local variable 'i' referenced before assignment
Почему так происходит?