python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread gintare
I run python33 scrupt SVtxt.py from Windows command line I want to print out the file contents to stdout. File contents: Vi kan inte längre underordna den vinster... Python script sentences i have tries to use: f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r') linef=f.readlines() f.close()

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread gintare
The answer is on page:https://docs.python.org/3.3/howto/unicode.html#reading-and-writing-unicode-data The correct code: f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') linef=f.readlines() print(repr(linef)) -- https://mail.python.org/mailman/listinfo/python-list

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Dave Angel
gintare g.statk...@gmail.com Wrote in message: The answer is on page:https://docs.python.org/3.3/howto/unicode.html#reading-and-writing-unicode-data The correct code: f=open('C:\Python33\Scripts\lang\langu\svtxt.txt','r', encoding='utf-8') linef=f.readlines() print(repr(linef)) But

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 4:05:10 AM UTC-5, gintare wrote: The correct code: f=open(snip-path,'r', encoding='utf-8') linef=f.readlines() print(repr(linef)) Yes but do you understand why? And even if you DO understand why, you should explain the details because the neophytes are always watching!

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Terry Reedy
On 7/6/2014 10:52 AM, Rick Johnson wrote: So the direct reason for failure is due to the fact that the print() function ONLY handles strings, not list objects. print(object()) object object at 0x020D2140 print(['abc', 'cdf']) ['abc', 'cdf'] Since the original poster did not copy

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 11:14:26 AM UTC-5, Terry Reedy wrote: On 7/6/2014 10:52 AM, Rick Johnson wrote: So the direct reason for failure is due to the fact that the print() function ONLY handles strings, not list objects. print(object()) object object at 0x020D2140

Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,

2014-07-06 Thread Rick Johnson
On Sunday, July 6, 2014 1:14:38 PM UTC-5, wxjm...@gmail.com wrote: Le dimanche 6 juillet 2014 18:53:34 UTC+2, Rick Johnson a écrit : [...] Seems like she'd better do the decoding before printing No or am i wrong again? Yes s = 'abc需' sys.stdout.encoding 'unicode' print(s)