int的作用
1.temp = input("请输入1到100之间的数字:")
num = int(temp)
if 1 <= num <= 100:
print('你妹好漂亮^_^')
else:
print('你大爷好丑T_T')
int的作用
2.
temp = input ('输入数字:')
int(temp)
print (temp*10)
求解
可能我没认真听课吧
将一个字符串变成数字。
比如
int('123')得到123
int('12321')得到12321 int整型类型。
强制类型转换 int(“111”)
是111,
int(“aaa”)
是:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
int("aaa")
ValueError: invalid literal for int() with base 10: 'aaa'
页:
[1]