我的Python3代码
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)
Run Code Online (Sandbox Code Playgroud)
如果我想取一个数字的正方形,为什么会出错?
unsupported operand type(s) for ** or pow(): 'str' and 'int'
Run Code Online (Sandbox Code Playgroud)
从命令行没问题
>>> 3**2
9
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11647 次 |
| 最近记录: |