2种方法:

1.open文件设置encoding

file = open(filename, 'r', encoding='UTF-8')

2.用encode方法

str = str.encode()

参考:https://www.fujieace.com/python/str-bytes.html

posted on 2020-07-04 22:55  西伯尔  阅读(766)  评论(0编辑  收藏  举报