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)  #测试用
相关推荐
2601_9563198820 分钟前
最新AI量化提效,先做可验证的小流程
人工智能·python
开飞机的舒克_2 小时前
FastAPI 实战入门:从路由、参数校验到依赖注入的后端开发指南
python·fastapi
霸道流氓气质2 小时前
Kiro 中反编译 JAR 包并分析字节码的流程指南
chrome·python·jar
人工智能时代 准备好了吗2 小时前
AI回答内容进入率监测:引用识别、文本匹配与语义判断
开发语言·人工智能·python
Metaphor6923 小时前
使用 Python 冻结 Excel 文件中的行、列和单元格
开发语言·python·excel
言乐63 小时前
Python实现建造微服务商城后台
开发语言·python·算法·微服务·架构
fenglllle4 小时前
chromadb emmbedding 向量检索
人工智能·python·embedding
cui_ruicheng4 小时前
Python从入门到实战(六):非序列容器
开发语言·python
百里香酚兰4 小时前
【python学习笔记】pyttsx3库疑似只播报一次语音
笔记·python·学习
飞猪~4 小时前
Langchain python版本 LLM 重要函数invoke,ainvoke,stream,astream,batch,abatch
python·langchain·batch