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

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

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

原代码:

driver.find_element_by_name("file").send_keys("C:UsersAdministratorDesktop upian.png")

解决方法:

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

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

原文地址:https://www.cnblogs.com/tianzhouDAN/p/8119389.html