品易云推流 关闭
文章详情页
文章 > Python基础教程 > python如何输入回车

python如何输入回车

Python 输入 回车

头像

爱喝马黛茶的安东尼

2019-10-10 11:22:3313737浏览 · 0收藏 · 0评论

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 = ''
for line in iter(raw_input, stopword): # 输入为空行,表示输入结束
  str += line + '\n'
 
# print (str)  #测试用
关注

关注公众号,随时随地在线学习

本教程部分素材来源于网络,版权问题联系站长!

底部广告图