AnsweredAssumed Answered

Dealing with accents on inputs for text files

Question asked by duckduck10 on Jul 25, 2012
Latest reply on Jul 26, 2012 by alanrussian
I am currently creating a textfile in which I would like to write the users input. it needs to be able to deal with characters that contain accents i.e."é". The file needs to be coded on utf-8
I have managed to copy into the text file using utf-8 coding by by using codecs. However, I am having a hard time figuring out how to do this given a users input?.. so far  i have something like this:

import codecs import sys   aninput = sys.argv[1]    textfile ="testfile","wt","utf-8") textfile.write(u"é") # this works  textfile.write(aninput) # this fails assuming that aninput = "é" textfile.close()

any ideas?