本以为是缺少utf-8造成的错误,但是加完这个还是报错,于是在网上百度了一下是因为上传的路劲粗无偶导致的

正确的写法是把路劲中“\”变为“\\”,或者在路劲的开头加上“r”,或者在路劲的开头加上“r”并且把“\”变为“/”

如下:

1、os.system('C:\\Users\\fyr\\Desktop\\auit.exe')

2、os.system(r'C:\Users\fyr\Desktop\auit.exe')

3、os.system(r'C:/Users/fyr/Desktop/auit.exe')

具体原因:

window读取文件可以用"\",但是在字符串中“\”是被当作转义字符来使用。

解决办法:

Python中描述路劲时可以有多种方式,以下是常见的三种:

   1、转义的方式

'd:\\a.txt'
2、显式声明字符串不用转义 'd:r\a.txt' 3、使用Linux的路径 'd:/a.txt'
在linux和window下都可以用第三种

selenium报错信息-- Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案的更多相关文章

  1. Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案

    window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,'C:\Users\FrankYuan\Pictures\Camera Roll\WIN_20161010_08_51_57_P ...

  2. 自动化上传图片,路径driver.find_element_by_id("oper-img-change").send_keys("C:\\Users\\76776\\Pictures\\logo.jpg"),为正确姿势,单\报错 'unicodeescape' codec can't decode bytes in position XXX: trun

    自动化上传图片,路径driver.find_element_by_id("oper-img-change").send_keys("C:\\Users\\76776\\P ...

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

    使用网页版jupyder在读取桌面文件时,刚开始我的代码是: baseball = pd.read_csv('C:\Users\TuZhiqiang\Desktop\result.csv')print ...

  4. 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 ...

  5. 报错: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 ...

  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. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Matcher的group()/group(int group)/groupCount()用法介绍

    直接上代码: package com.dajiangtai.djt_spider.util; import java.util.regex.Matcher;import java.util.regex ...

  2. The Truth About GCHandles

    I've heard several people asking why GCHandle doesn't implement IDisposable, considering it wraps an ...

  3. WebView根据加载的内容来控制其高度

    一.先设置WebView的高度为0,然后在其加载结束后的代理方法中根据contentSize设置其高度 //初始话一个UIWebView: self.webView = [[[UIWebView al ...

  4. 关于 == 和 equals() 的区别

    对于正在学习java的,以及入行不久的小伙伴们,在面试中经常会被面试官问到 "  == 和 equals() 的区别 ?"的问题,你是否回答好了呢? 示例一: //两个基本类型数据 ...

  5. 安装coreseek 编译错误

    Ubuntu下 编译csft 报错fatal error python.h no such file or directory 执行apt-get install python-dev即可

  6. mysql给id生成uuid

    mysql中id一般都设为uuid,除了我们在后台用到的uuid利用jpa注解来生成外,其实在mysql中直接也可以生成 直接上代码: 1.mysql中直接使用uuid()函数,可以生成一个随机的uu ...

  7. OVN学习(三)

    部署OVN实验环境 同OVN学习(一) 网关 在L3网络基础上部署网关 添加L3网关 ### Central节点 # ovn-sbctl show Chassis "8bd09faf-5ba ...

  8. CentOS 安装配置vncserver

    yum 安装tiger vncserver yum install tigervnc-server 安装后输入 vncserver 设置密码 3.配置用户 vim /etc/sysconfig/vnc ...

  9. centos6上安装CDH5.7

    目录 一.环境说明及所需软件包... 1 1.环境说明... 1 2.所需软件及说明... 1 二.安装前的主机准备(所有主机都有做) 2 1.配置主机名和修改host文件... 2 2.下载系统基本 ...

  10. Codeforces 1152E(欧拉路径)

    看样例然后发现只要求一个一笔画即可,用板子. #include <cstdio> #include <cstring> #include <iostream> #i ...