Thanks Nobody-38, it solved my problem immediately. --Thanks Again, Akhil
Nobody-38 wrote: > > On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote: > >> Well, you were write: unintentionally I removed strip(). But the problem >> does >> not ends here: >> >> I get this error now: >> >> File "./temp.py", line 488, in <module> >> main() >> File "./temp.py", line 475, in main >> for line in sys.stdin: >> File "/usr/local/lib/python3.1/codecs.py", line 300, in decode >> (result, consumed) = self._buffer_decode(data, self.errors, final) >> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 0-2: >> invalid >> data >> >> for this line: >> รข > > Right. You're running in a locale whose encoding is UTF-8, but feeding > data which isn't valid UTF-8 to stdin. If you want to use data with a > different encoding, you need to replace sys.stdin, e.g.: > > import sys > import io > sys.stdin = io.TextIOWrapper(sys.stdin.detach(), encoding = 'iso-8859-1') > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- View this message in context: http://www.nabble.com/UnicodeEncodeError%3A-%27ascii%27-codec-can%27t-encode-character-u%27%5Cxb7%27-in-position-13%3A-ordinal-not-in-range%28128%29-tp24509879p24550497.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list