Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #74004

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

Newsgroups comp.lang.python
Date 2014-07-06 01:45 -0700
Message-ID <b447a73e-cad2-4448-abff-675a3b387e9b@googlegroups.com> (permalink)
Subject python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position, to print out the file contents to stdout,
From gintare <g.statkute@gmail.com>

Show all headers | View raw


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()
print(linef)#gives error
print(linef).decode("utf-8","ignore")#gives error

ERROR:
c:\Python33\Scripts\lang\langu>python SVtxt.py
Traceback (most recent call last):
  File "SVtxt.py", line 8, in <module>
    print(linef).decode("utf-8","ignore")
  File "C:\Python33\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 91-92:

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, gintare <g.statkute@gmail.com> - 2014-07-06 01:45 -0700
  Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, gintare <g.statkute@gmail.com> - 2014-07-06 02:05 -0700
    Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, Dave Angel <davea@davea.name> - 2014-07-06 08:57 -0400
    Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 07:52 -0700
      Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, Terry Reedy <tjreedy@udel.edu> - 2014-07-06 12:14 -0400
        Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 09:53 -0700
          Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, wxjmfauth@gmail.com - 2014-07-06 11:14 -0700
            Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, Rick Johnson <rantingrickjohnson@gmail.com> - 2014-07-06 12:37 -0700
              Re: python33, windows, UnicodeEncodeError: 'charmap' codec can't encode characters in position,  to print out the file contents to stdout, wxjmfauth@gmail.com - 2014-07-06 23:58 -0700

csiph-web