hellow all, I'm working with python 3.6.0 on a project in pycharm community edition 2016.3.2. I have this strange error happens in my program whenever I use codecs to encode my input stream:
import codecs
import sys
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
print("something")
the problem is my program always exit with an exit code 1, and here is the console output:
Traceback (most recent call last):
File "C:/Users/jhonsong/Desktop/restfulAPI/findARestaurant.py", line 9, in <module>
print("something")
File "C:\Python36-32\lib\codecs.py", line 377, in write
self.stream.write(data)
TypeError: write() argument must be str, not bytes
Process finished with exit code 1
but my input is a string, why is codecs.write think I'm giving it bytes input?