selenium报错信息-- Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案

本以为是缺少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错误解决方案的更多相关文章
- Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案
window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,'C:\Users\FrankYuan\Pictures\Camera Roll\WIN_20161010_08_51_57_P ...
- 自动化上传图片,路径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 ...
- (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 ...
- 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 ...
- 报错: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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 【241】◀▶IEW-Unit06
Unit 6 Advertising 多幅柱子在一幅图中的写作技巧 1.Model1图片分析 The bar chart contains information about the amount o ...
- 当在hive中show table …
当在hive中show table 时如果报以下错时 FAILED: Error in metadata: javax.jdo.JDODataStoreException: Error(s) were ...
- 算法java实现--回溯法--图的m着色问题
(转自:http://blog.csdn.net/lican19911221/article/details/26264471) 图的m着色问题的Java实现(回溯法) 具体问题描述以及C/C++实现 ...
- 日期组件wdatepicker
导入WdataPicker文件包到项目的js文件夹下: 在用户管理中的添加.编辑jsp页面对生日表单项引入日期组件: <script type="text/javascript&quo ...
- Sharepoint2013搜索学习笔记之修改搜索拓扑(三)
搜索服务新建好之后可以从管理中心,应用程序管理页面,进入搜索服务的管理页面,进入管理页面之后可以看到当前sharepoint场的搜索拓扑结构. 如果sharepoint场内有多台服务器,需要将搜索组件 ...
- ASP.NET in C#,ClientScript.RegisterStartupScript与ClientScript.RegisterClientScriptBlock用法之己见
ClientScript.RegisterStartupScript:http://msdn.microsoft.com/zh-cn/library/system.web.ui.clientscrip ...
- GridView.SelectedIndex
获取或设置 GridView 控件中的选中行的索引. C#复制 [System.ComponentModel.Bindable(true)] public virtual int SelectedIn ...
- unity5.5打包
https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildAssetBundles.html 5.34升5.5打包bundle遇到问题 A ...
- 洛谷P2950 [USACO09OPEN]牛绣Bovine Embroidery
P2950 [USACO09OPEN]牛绣Bovine Embroidery 题目描述 Bessie has taken up the detailed art of bovine embroider ...
- shell脚本编程入门
Linux的Shell种类众多,这里我们关注的重点是Bash. 基本语法 环境变量$PATH IO重定向: 以<改变标准输入 如:tr -d '\r' < dos-file.txt 以& ...