Форум сайта python.su
0
Добрый день!
Прохожу курс “Гийденко - Воркшопы по Python и PyQT”.
Все вроде нормально.
Но этот скрипт выдает ошибку.
import os import shutil path = r'c:\Users\user\Downloads\44' correctname = 'shot_01' padding = 4 # list of files tmp = os.listdir(path) files = [] for t in tmp: if os.path.isfile(os.path.join(path, t)): files.append(t) # separate frames=[] for f in files: name, ext = os.path.splitext(f) fullname = name while name[-1].isdigit(): name=name[:-1] digits = int(fullname.replace(name,'')) frames.append(digits) offset = min(frames)-1 # new name outfolder = os.path.join(path,correctname) if not os.path.exists(outfolder): os.mkdir(outfolder) for i, f in enumerate(files): print(i,f) old = os.path.join(path, f) name, ext = os.path.splitext(f) newName = correctname + '_' + str(frames[i]-offset).zfill(padding) + ext new = os.path.join(path, correctname, newName) if os.path.exists(new): os.remove(new) shutil.copy2(old, new) # search missing frame fullrange = range(min(frames), max(frames)+1) miss = [] for i in fullrange: if not i in frames: miss.append(i) #message print('Miss frame:', miss) a = input('Remove old files? [y/n]: ') if a == 'y': for f in files: os.remove(os.path.join(path, f)) print(a) input()
Remove old files? : y
Traceback (most recent call last):
File “test.py”, line 49, in <module>
a = input('Remove old files? : ‘)
File “<string>”, line 1, in <module>
NameError: name ’y' is not defined
Офлайн
.
Отредактировано J.R. (Фев. 28, 2016 12:44:31)
Офлайн
857
ImardenВидимо, он для третьего питона, так что лучше поставить третий, иначе все примеры придётся переделывать.
Прохожу курс “Гийденко - Воркшопы по Python и PyQT”.
Офлайн
0
Спасибо. Курс по второму питону. Это моя ошибка.
Офлайн