unsupported operand type(s) for ** or pow(): 'str' and 'int' with Python3
本问题已经有最佳答案,请猛点这里访问。
我的Python 3代码
1 2 3 4 5 6 7 8 9 10 11 12 13 | def ask(): while True: try: n = input('Input an integer: ') except: print ('An error occurred! Please try again!') continue else: break print ('Thank you, you number squared is: ', n**2) |
如果我想取一个平方,为什么会出错?
1 | unsupported operand type(s) for ** or pow(): 'str' and 'int' |
从命令行没有问题
1 2 | >>> 3**2 9 |