使用网页版jupyder在读取桌面文件时,刚开始我的代码是:

baseball = pd.read_csv('C:\Users\TuZhiqiang\Desktop\result.csv')
print(baseball)

一直报错:

(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

后来发现:

在Python中 是转义符,\u表示其后是UNICODE编码,因此\User在这里会报错,在字符串前面加个 r(rawstring  原生字符串),可以避免python与正则表达式语法的冲突!

修改后:

baseball = pd.read_csv(r'C:\Users\TuZhiqiang\Desktop\result.csv')
print(baseball)

结果正常:

(unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape 错误的更多相关文章

  1. 出错:(unicode error) 'unicodeescape' codec can't decode bytes in position 8-9: malformed \N character escape

    报错原因:python 中 \N 是换行的意思.这里要把 N 前面的 \ 转义一下.用  \\  代替即可. Nokia_mac = np.loadtxt('data\oui\\NokiaMac201 ...

  2. SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    "F:\program files (x86)\Python35\python.exe" "F:/program files (x86)/JetBrains/Seleni ...

  3. Python--错误SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    Refer to:https://www.cnblogs.com/cyiner/archive/2011/09/18/2180729.html 用Python打开文件: fo=open("C ...

  4. 报错:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    Outline SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: trunc ...

  5. SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape错误原因及解决方法

    用Python打开文件: with open('C:\Users\PINPIN\test\file1.txt','r') as f2: pass 运行后直接就报错了: File "<i ...

  6. Python中出现 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 12-13: truncated \UXXXXXXXX escape

    Python中出现 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 12-13: t ...

  7. Python报错:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

    运行python文件的时候报错: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2 ...

  8. Python中读取txt文本出现:SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape问题解决

    windows中的路径是反斜杠\,然而反斜杠\在python中有着转义字符的意义,所以在py文件中写windows文件路径的时候,要特别注意反斜杠\的使用. 下面有三种解决方式: 方式一:转义的方式 ...

  9. 18-(unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \uXXXX escape

    读取文件时碰到问题: 1.(unicode error) 'unicodeescape' codec can't decode bytes in position 16-17: truncated \ ...

随机推荐

  1. QT + openssl + VS2015静态编译

    从http://slproweb.com/products/Win32OpenSSL.html下载已经编译好的openssl,一路next 我将OpenSSL-Win32\lib\VC目录下的libe ...

  2. ubuntu 安装phpunit

    一.下载安装 wget https://phar.phpunit.de/phpunit-7.2.phar chmod +x phpunit-7.2.phar sudo mv phpunit-7.2.p ...

  3. Code Festival 2017 Qual B E Popping Balls

    传送门 神仙计数! 我的计数真的好差啊= = 不过这个题真的神仙 看了题解把整个过程在草稿纸上重写了一遍才想明白= =(一张草稿纸就没有了!!!) 计数的关键就是在于 枚举的有效性和独立性[不能重复计 ...

  4. java 根据excel模板导出文件

    <!--读取excel文件,配置POI框架的依赖--> <dependency> <groupId>org.apache.poi</groupId> & ...

  5. 【和孩子一起学编程】 python笔记--第五天

    关于python2在python3中的改动: https://mp.weixin.qq.com/mp/appmsg/show?__biz=MjM5MDEyMDk4Mw==&appmsgid=1 ...

  6. 大量TIME_WAIT连接的解决办法

    1.使用keep alive连接(待补充) 2.修改tcp参数 根据TCP协议的连接断开规定,发起socket主动关闭的一方,socket将进入TIME_WAIT状态,TIME_WAIT状态将持续2个 ...

  7. Python3解leetcode Rotate Array

    问题描述: Given an array, rotate the array to the right by k steps, where k is non-negative. Example 1: ...

  8. http 换成 https

    UPDATE SYS_MENU M SET M.href = ( SELECT CASE WHEN substr(N.href, 0, 5) = 'http:' THEN 'https:'||subs ...

  9. && 和 || 逻辑运算符的短路运算

    &&和||的短路运算,是指如果在进行前面的表达式的运算过程,通过判断已经明确的知道整个表达式的结果,那么就不会进行后面表达式的运算判断. 表达式1 || 表达式2 || 表达式3... ...

  10. 【HDOJ6604】Blow up the city(支配树)

    题意:给定一个n点m边的DAG,将只有入边的点称为周驿东点 q次询问,每次给定a,b两点,询问删去某个点x和其相连的所有边,能使a,b至少其中之一不能到达任何周驿东点的x的个数 n,q<=1e5 ...