1
You got error because Python 2
‘s default ASCII encoding was used. Characters greater than 127 cause an exception so use str.encode
to encode from Unicode to text/bytes.
Good practice is to use with
keyword when dealing with file objects.
path = u''.join((file_path, user_org, '_', fileName)).encode('utf-8')
with open(path, 'w+') as f:
f.write(fileData)
Source:stackexchange.com