python - Python list 和 int 仅在调试时有效
问题描述
我正在编写一个代码,在运行时给我一个dropd
只有 1 个项目的列表,一个age
应该是 int 的变量继续一个字符串。
当我在调试模式下使用代码时,我注意到如果我只执行列表dropd
行,那么它会给我正确的项目,如果我age = int(agee)
单独执行,那么它会给我一个 int 作为结果。
这是怎么回事?
if sistema_selected == 2:
self.driver.switch_to.frame(self.driver.find_element_by_xpath("//iframe[@data-id='1']"))
...
time.sleep(3)
try:
print('CPF Valido')
self.driver.find_element_by_xpath('//*[@id="mudarMatricula"]/div/div/select').click()
dropd = self.driver.find_elements_by_xpath(
'/html/body/div[2]/div[2]/div[2]/div[4]/div/form/
div[1]/div/div/div/div[2]/div[1]/h3/span[1]/div/div/select/option')
i = 0
for item in dropd:
time.sleep(1)
item.click()
...
agee = idade_split[idade_split.index('Anos') - 1]
age = int(agee)
...
if age < 75:
idade_plc = Label(frame_idade, text=age, borderwidth=1, relief="groove")
idade_plc.grid(row=i + 1, column=0, sticky=EW)
elif age > 75:
idade_plc = Label(frame_idade, text=age, borderwidth=1, relief="groove", bg='red')
idade_plc.grid(row=i + 1, column=0, sticky=EW)
nome_plc = Label(frame_nome, text=nome)
nome_plc.grid(row=0, column=1, sticky=EW)
...
# IF THE CLIENT CODE IS WRONG
except (NoSuchElementException, UnexpectedAlertPresentException):
print('CPF Invalido')
解决方案
推荐阅读
- reactjs - apollo 客户端在创建页面时给出错误 500
- flutter - 如何解决方法 '<' 在 null 上被调用。接收者:null 尝试调用:<(0.0)?
- tensorflow - Keras EfficientNet 迁移学习代码示例不起作用
- charts - 如何更改 ChartJS 线段中的 pointBackgroundColor?
- python-3.x - 如何在 Python 中增量更新函数的结果
- flutter - 将 SignalR 与 Flutter 一起使用时循环 OnConnected
- c# - 从类构造函数调用返回值
- javascript - 从函数中导出数据 [mysql, node.js, discord.js]
- loops - 输入无效的布尔值会导致 infin 错误。循环并阻止我输入更多信息
- ios - 如何防止 App Store Connect 询问仅 iPad 应用程序的 iPhone 屏幕截图?