|
发表于 2021-7-24 19:56:55
|
显示全部楼层
本帖最后由 Python初学者8号 于 2021-7-24 19:59 编辑
你可以打开idle的按住F1搜索“input()”,然后你会看到这个
input([prompt])
If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.
这个意思就是:
input(‘这是一个提示性的字符串’)
这个函数,本身的作用是读取一个字符串,该字符串从括号中的字符串‘这是一个提示性的字符串’显示完毕之后开始,然后在你按住回车之后作为结束,并且将这个字符串当做本次调用input函数的输出结果
一句话,不加int后,你的tmep是一个字符串类型。所以,字符串temp不可以有加1这个操作的,所以,就将其变为数字咯——也即为int(tempt) |
|