(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escap
在读取桌面文件的时候一直报错:(unicode error) ‘unicodeescape’ codec can’t decode bytes in position 2-3: truncated \UXXXXXXXX escape
自己刚开始写的是这样的:
import scipy as sp
data = https://www.it610.com/article/sp.genfromtxt(“C:/Users/Administrator/Desktop/Machine Learning/web_traffic.tsv”,delimiter=”/t”)
后来发现,在Python中\是转义符,\u表示其后是UNICODE编码,因此\User在这里会报错,在字符串前面加个r表示就可以了
import scipy as sp
【(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escap】data = https://www.it610.com/article/sp.genfromtxt(r”C:/Users/Administrator/Desktop/Machine Learning/web_traffic.tsv”,delimiter=”/t”)
推荐阅读
- python学习|windows如何安装并切换不同版本的cuda,更新cuda版本
- python-Django如何可以用真实的IP访问(四)
- 各种算法的Python实现方案
- C++|Leetcode 076 最小覆盖子串 Python C++ 史上最详细题解系列
- raise ImportError(msg.format(path)) ImportError: Something is wrong with the numpy installation
- python|Anaconda 之 更换国内下载镜像
- python安装channels报错(" Failed building wheel for Twisted")
- 利用百度智能云结合Python体验图像识别
- Jieba库与wordcloud库的学习汇总