当前位置:首页 > 云计算 > 正文内容

python如何输入回车

2022-05-04 03:02:32云计算1

Python默认遇到回车的时候,输入结束。所以我们需要更改这个提示符,在遇到空行的时候,输入才结束。

相关推荐:《Python教程》

raw_input就是从标注输入读取输入,输入的是什么就是什么。

文档解释:The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

stopword=''#输入停止符
str=''
forlineiniter(raw_input,stopword):#输入为空行,表示输入结束
str+=line+'\n'

#print(str)#测试用

本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.

本文链接:https://www.xibujisuan.cn/4388.html

标签: Python