python - 为什么即使条件为真,我的 If 语句也不起作用,但如果条件为真,则 else 仍在工作
问题描述
我有一个简单的 if else 语句,但我有一个问题,为什么即使 if 条件为真但 if 条件不起作用,但当 else 为真时它工作正常。
有人可以告诉我为什么我的 if 条件即使是真的也不起作用?
self.comboBoxCourse.currentIndexChanged.connect(self.courseChoosed)
这是 if else 语句:
def courseChoosed(self):
if self.comboBoxCourse.currentIndex() == 0:
self.pushButton_2.clicked.connect(self.courseSTEM)
print("Your Current course is STEM")
elif self.comboBoxCourse.currentIndex() == 1:
self.pushButton_2.clicked.connect(self.courseICT)
print('Your current course is ICT')
print(self.comboBoxCourse.currentIndex())
如果我选择 STEM 这是 Index == 0: 这是真的,它正在显示打印消息,我不知道为什么但按钮不起作用。
如果组合框为 ==1: 并且按钮工作得很好,则 else 语句的结果。
有人可以告诉我为什么 if 语句中的按钮功能即使是真的也不起作用?
解决方案
推荐阅读
- javascript - 用于替换中间字母的正则表达式
- javascript - 输入导致链接更改的输入
- java - 有没有办法使用 Python 生成 Java 源代码的抽象语法树?
- css - 孩子 div 是否继承父母的身高?
- windows - 无法运行 git clone 或 pip install 命令
- android - StackOverflowError 与 lint
- ios - 如何在 CollectionView 中添加页脚/页眉
- vuejs2 - Vue停止列表/扩展
- java - JDK12 的 Java 运行时版本
- javascript - React,想要获取当前元素的当前鼠标位置