本文整理汇总了Python中Base.Base.stringToBase方法的典型用法代码示例。如果您正苦于以下问题:Python Base.stringToBase方法的具体用法?Python Base.stringToBase怎么用?Python Base.stringToBase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Base.Base
的用法示例。
在下文中一共展示了Base.stringToBase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OnInputChanged
# 需要导入模块: from Base import Base [as 别名]
# 或者: from Base.Base import stringToBase [as 别名]
def OnInputChanged(self, *args): #args just catches tkinter arguments. I don't need them
self.operand1 = (self.input_operand1.get(), Base.stringToBase(self.input_base1.get()))
self.operand2 = (self.input_operand2.get(), Base.stringToBase(self.input_base2.get()))
operator = Operator.stringToOperator(self.operator.get())
if self.canCalculate(operator):
operand1 = convert(self.operand1[0], self.operand1[1], Base.decimal)
# edge case not operation, operand2 could be invalid
if operator != Operator.NOT:
operand2 = convert(self.operand2[0], self.operand2[1], Base.decimal)
else:
operand2 = None
# edge case div by zero
if operator == Operator.DIV and float(operand2) == 0:
self.outputError('2', "Can't divide by 0")
self.outputResults('result', clear=True)
return
try:
self.result = (result(operand1, operand2, operator), Base.decimal)
self.outputResults('result')
except Exception as e:
print("Calculation: ", e)
else:
self.outputResults('result', clear=True)