若尝试以下无效
函数('地址',encoding='UTF-8')
重启spyder可能有效
根本解决方法是:
修改文件C or D:\****\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py,spyder重启后生效。
def get_file_code(filename):
"""Retrive the content of a file."""
# Get code from spyder
try:
file_code = frontend_request().get_file_code(filename)
except (CommError, TimeoutError):
file_code = None
if file_code is None:
with open(filename, 'r',encoding='utf-8') as f:#增加 ,encoding='utf-8'
return f.read()
return file_code
参考资料:
https://blog.youkuaiyun.com/zhangpeterx/article/details/103843773