如何解决在IF陈述中使用储存格值
我正在查找一个单元格值,如果该单元格未输入任何内容,我希望我的代码不执行任何操作,否则我想出于某种原因在Tkinter画布上放置标签,无论我做什么标签总是最终显示出来,下面的代码可以工作吗?
##Grabbing the cell value from that indexed row and specific column,in this case pulling the value of indexed cell and column "Zixi Device"
Searched_Service_Row_Location_B = (excel_data_df.iloc[Searched_Service_Row_Location]["Zixi Device"])
Searched_Service_Row_Location_B_Value = (Searched_Service_Row_Location_B.values)
然后我在IF语句中使用var Searched_Service_Row_Location_B_Value
if Searched_Service_Row_Location_B_Value == None:
pass
else:
Source1 = Label(Standard_window,text=Searched_Service_Row_Location_B_Value)
Source1.place(x=60,y=100)
即使var中存储的单元格值在excel文档中未输入任何内容,Source1标签也始终显示。
解决方法
这似乎可以按照我想要的方式工作
if str(Searched_Service_Row_Location_B_Value) in (None,"[nan]"):
pass
else:
Source1 = Label(Standard_window,text=Searched_Service_Row_Location_B_Value)
Source1.place(x=60,y=100)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。