user3376321
user3376321

Reputation: 839

unicode (utf8) writing (Arabic, Hebrew,chines) to files in the cloud storage, Python

I would like to write to a file in multiple language and after then store it in the cloud storage.this my code:

file=gcs.open(filename,'w',content_type='text/html; charset=utf-8')

      file.write(str(content))
      file.close()

How could I modify it ? thank you

Upvotes: 1

Views: 1520

Answers (1)

JJ Geewax
JJ Geewax

Reputation: 10579

Looks like this might be an issue of encoding your string as UTF-8 before calling file.write. How about:

file.write(content.encode('utf-8'))

Upvotes: 4

Related Questions