首页 > 代码库 > Python UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

Python UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)

#!/usr/bin/python
# -*- coding: utf-8 -*-

 

技术分享

解决方法:

技术分享

可以看到我的版本是2.6的,所以打开/usr/lib64/python2.6/site.py

技术分享

红框里本来是0,把这个0改为1就可以了。

Python UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)