python使用send_keys上传图片报错解决

使用send_keys上传图片错误提示:

················ 'unicodeescape' codec can't decode bytes in position 2-3···············

 

原代码:

driver.find_element_by_name("file").send_keys("C:\Users\Administrator\Desktop\tupian.png")

 

解决方法:

上传图片地址需要修改如下:

driver.find_element_by_name("file").send_keys("C:\\Users\\Administrator\\Desktop\\tupian.png")

posted @ 2017-12-26 18:08  我是田舟  阅读(638)  评论(0编辑  收藏  举报