读取文件时报错:
SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 105-106: truncated \uXXXX escape
文件路径为:F:…(省略了中间路径)\urls.txt
在file_path = 'F:…(省略了中间路径)urls.txt’中没有出现报错,以为这种写法可以。
当出现报错时,去pycharm中修改文件编码结果没有用。
找到博主Your-Nikee《SyntaxError: (unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UX》才知道还是路径问题,路径必须加上双斜杠
‘F:\…\urls.txt’
读取成功
[1]https://blog.csdn.net/YourNikee/article/details/102738764