Traceback (most recent call last):В общем такая ошибка появляется после запуска скрипта, хотя в директории лежит 2 txt файла 222.txt и 333.txt
File “C:\files.py”, line 17, in <module>
list_files(0, ‘*.txt’, unicode('c:\dwn', ‘cp1251’))
File “C:\files.py”, line 15, in list_files
os.remove(path + “\\” + name)
WindowsError: : u'c:\\dwn\\\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435.txt'
Не могу понять откуда он берет c:\\dwn\\\u041e\u0433\u043b\u0430\u0432\u043b\u0435\u043d\u0438\u0435.txt
Вот код:
# -*- coding: cp1251 -*-
from os.path import join, getsize
import os
import fnmatch
def list_files(norm_size, file_ext, path):
num = 0
for root, dirs, files in os.walk(path):
for name in files:
SizeFile = getsize(join(root, name))
if SizeFile > norm_size:
if fnmatch.fnmatch(name, file_ext):
num = num + 1
print str(num) + " |" , name + " |", str(SizeFile) + " |", root + " deleted"
os.remove(path + "\\" + name)
list_files(0, '*.txt', unicode('c:\dwn', 'cp1251'))