获取python组合框的条目并转换为大写

2024-09-30 02:34:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我围绕两个组合框构建了一个程序,用户可以在其中输入数字。下拉列表由下面csv文件的第一列组成。在用户在组合框中输入数字后,我使用.get()获取该数字,并在csv中搜索该数字,以获取相关数字以显示在CB2中。然后,这两个条目用于在第二个GUI窗口中显示图片。 因为CSV的第三列中只有大写字母,所以我想将第二个组合框条目(按用户)转换为大写。通过print()检查,一切正常,k和u被转换。但是,它似乎不再在CSV中找到,因此无法找到相应的图片路径

代码如下:

eingabe_index = str(eingabefeld_index.get())
eingabe_index = str(eingabe_index.upper())
print(eingabe_index)
motorttnr = [x[0] for x in daten]
index = [x[2] for x in daten]
filter_motorttnr = filter(lambda a: eingabe_motor in a, daten)
liste_filter_motorttnr = list(filter_motorttnr)
filter_index = filter(lambda a: eingabe_index in a, liste_filter_motorttnr)
liste_filter_index = list(filter_index)

我尝试了使用和不使用强制输入字符串。 我能做些什么来解决这个问题

CSV的示例:

130822060;060_Motor.gif1K1;5.060_Lage_1K1.gif;20;1K1_1_kunsttoffbox.gif 130822060;060_Motor.gifU30;52;060_Lage_U30_Text.gif;780;1K1_Kunststoffbox_gruene_Stollen_Text.gif

130822061;061_Motor.gif;U30;52;061_Lage_U30_Text.gif;780;1K1_Kunststoffbox_gruene_Stollen_Text.gif

130822061;061_Motor.gif;1K1;52;061_Lage_1K1.gif;780;1K1_1_kunsttoffbox.gif


Tags: csvtext用户inindex数字filtergif

热门问题