character encoding - Python: How do I force iso-8859-1 file output? -


How can I apply the file output to Python in Latin-1 (which I think iso-8859-1?) Am I

This time my code is working, but the result is trying to import the output file into Latin-1 MySQL table.

  for outputfile = file ("textbase.tab", "w"), in textData v .iteritems (): full_line = k + '~~~~~' + v + '~~~~~' + "" content "output file. Written (full_line) outputFile.write (" \ n ") outputFile.close ()  

The resultant output file is" Western ( Mac OS Roman) ", but if I save it in Latin-1, then I still get awkward encoding problems. How can I ensure that the strings are used, and the files As soon as they occur in Latin-1, they are encoded?

The original strings ( textData dictionary) have been parsed with an RTF file - I do not know that it makes a difference

I'm new to Python and is new to generally encoding, so sorry if this is a dumb question. I tried to see the docs But have not been found too far.

I use Python 2.6.1 I am doing this.

Simply use the module to write the file:

  import codecs outputFile = codecs.open ("textbase.tab", "w", "ISO- Definitely, the stars you write should have Unicode string (type  unicode ) , If they are plain they will not change.  str  objects (which are basically an array of bus bytes) I think you are also reading the RTF file with the normal Python file object, so you may have to change that code as  codecs.open  too. 


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -