Samuel-wei / FilesProcessing

Merge multiple file into a file
0 stars 0 forks source link

UnicodeEncodeError: 'utf-8' codec can't encode characters in position 25-36: surrogates not allowed #1

Open Samuel-wei opened 3 years ago

Samuel-wei commented 3 years ago

Output Error:

UnicodeEncodeError: 'utf-8' codec can't encode characters in position 25-36: surrogates not allowed
Samuel-wei commented 3 years ago

Solving:

https://python3-cookbook.readthedocs.io/zh_CN/latest/c05/p15_printing_bad_filenames.html

with open(new_file, 'w') as file_object: change to: with open(new_file, 'w', encoding='utf-8') as file_object: