使用网页版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. 【LeetCode】回溯法 backtracking(共39题)

    [10]Regular Expression Matching [17]Letter Combinations of a Phone Number [22]Generate Parentheses ( ...

  2. ivew-admin 校验 自定义验证表单多层嵌套

    1.prop=对象 <FormItem label=" prop="shapeDifference.heightSpaceT2"> <Input v-m ...

  3. Java实现线程的两种方式?Thread类实现了Runnable接口吗?

    Thread类实现了Runnable接口吗? 我们看看源码中对与Thread类的部分声明 public class Thread implements Runnable { /* Make sure ...

  4. hadoop中mapreduce的mapper抽象类和reduce抽象类

    mapreduce过程key 和value分别存什么值 https://blog.csdn.net/csdnliuxin123524/article/details/80191199 Mapper抽象 ...

  5. python 图像处理中二值化方法归纳总结

    python图像处理二值化方法 1. opencv 简单阈值 cv2.threshold 2. opencv 自适应阈值 cv2.adaptiveThreshold 3. Otsu's 二值化 例子: ...

  6. vue项目中使用echarts地图

    第一步.npm install echarts 第二部.在main.js中引入 第三步.创建组件,并且用this.$echarts.init初始化echarts <template> &l ...

  7. centos6安装完成之后必要的配置

    centos6安装完成之后必要的配置 一配置yum源 [root@centos61 ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirro ...

  8. 系统信息&&硬件信息查看

    系统信息&&硬件信息查看 一系统信息查看 (一)查看系统版本信息 [root@centos7 ~]# cat /etc/redhat-release CentOS Linux rele ...

  9. ps示例

    博客PS示例 一显示指定真正用户名(RUID)或用户ID的进程 打开另外一个终端 [root@centos72 ~]# id wang uid=1000(wang) gid=1000(wang) gr ...

  10. .NET Core 通过 Ef Core 操作 Mysql

    1.运行环境 开发工具:Visual Studio 2017 JDK版本:.NET Core 2.0 项目管理工具:nuget 2.GITHUB地址 https://github.com/nbfujx ...