Python deleting file with Unicode characters -


i writing cleanup method in python 2 should erase files including ones unicode name. shutil.rmtree not option since lacks control need.

at moment tried declaring # -*- coding: utf-8 -*- , use combinations of .encode('utf-8') , .decode('utf-8') no success. how method looks without encoding or decoding

def _remove_files(path):     files = []      dirpath, dirnames, filenames in os.walk(path):         filename in [f f in filenames]:             files.append(os.path.join(dirpath, filename))      _file in files:         print _file         os.chmod(_file, stat.s_irwxu | stat.s_irwxg | stat.s_irwxo)         os.remove(_file) 

this error get:

windowserror: [error 2] system cannot find file specified: u'c:\users\xxxxx\yyyyy\\u65e5\u672c\u8a9e\u306e\u656c\u8a9e.txt'


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -