【Python】UnicodeEncodeError 1

UnicodeEncodeError: 'ascii' codec can't encode characters in positio


// 检查编码

>>> import sys

>>> sys.getdefaultencoding()

'ascii'

>>> 


// 在main里面,设置编码为 utf-8

def main():

# prepare env

reload(sys)

sys.setdefaultencoding('utf-8')


你可能感兴趣的:(python,utf-8,encoding)