【发布时间】:2023-02-04 19:10:57
【问题描述】:
现在,我正在放大我的代码的一部分,如下所示:
qty = int(input('enter current quantity :'))
if qty != int:
print('input is not integer')
在上面的块中,我还通过了“5” 它返回“输入不是整数”...
所以我尝试运行以下代码:
type(qty)
运行此命令后,输出为“str”
- 有谁知道我可以更改什么以便正确转换输入?
我试过....
#notice how i removed the space between '=' and 'int'
qty =int(input('enter current quantity :'))
if qty != int:
print('input is not integer')
这次,出现了同样的信息……然而,
type(qty)
返回它已成功转换为“int”
【问题讨论】: