如何获得最佳性能?

时间:2019-07-21 13:41:40

标签: python python-3.x

在我的GUI计算器程序中,我有一个标签operation_screeen和一个箭头按钮pushButton_arrow,用于删除用户输入的最后一位数字。我的问题是:使它正常工作的最佳选择是什么(我知道我们只说了几毫秒):

首先,我们将其连接到其功能: self.pushButton_arrow.clicked.connect(self.rmv_last_digit)

然后我们有了rmv_last_digit函数:

def rmv_last_digit(self):
    last_digit_removed = self.operation_screen.text()[:-1]

这是我的问题:我是否每次都需要执行此操作

    self.operation_screen.setText(last_digit_removed)

或检查self.operation_screen.text()是否为空:

    if self.operation_screen.text() == '':
        pass
    else:
        self.operation_screen.setText(last_digit_removed)

哪个是更好的选择?

0 个答案:

没有答案
相关问题