这段代码适用于输入文件的第一行,但在第二次试用中失败了,我不知道为什么。我试图看看是否有类似的问题,但我没有找到解决办法。你知道吗
carac=":"
fichier = open("test", "r")
for i in range(2):
time.sleep(0.5)
chaine = fichier.readline().split(carac)
print(chaine[0])
driver = webdriver.Chrome(r'C:\Users\bh\Downloads\chromedriver')
driver.get('https://www.twitter.com/login')
username_box = driver.find_element_by_class_name('js-username-field')
username_box.send_keys(chaine[0])
password_box = driver.find_element_by_class_name('js-password-field')
password_box.send_keys(chaine[1])
我有一个错误:
Traceback (most recent call last):
File "C:/Users/bh/PycharmProjects/test/twitter.py", line 199, in <module>
password_box.send_keys(chaine[1])
IndexError: list index out of range
ps:文档是一个.txt文件 文档中有这样的内容:
test@gmail.com:pass
test@gmail.com:pass
发生这种情况是因为您没有为chaine[1]赋值。 你需要在使用前申报。为什么使用睡眠功能? 打印chaine[1]以查看其是否为空
相关问题 更多 >
编程相关推荐