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)  #测试用
相关推荐
耶夫斯计6 分钟前
【SQL_agent】基于LLM实现sql助理
数据库·python·sql·语言模型
vibag7 分钟前
RAG向量数据库
python·语言模型·langchain·大模型
kisshuan123967 分钟前
基于YOLO11改进的C3k2-AdditiveBlock实现命中检测与双重命中事件识别_1
python
mg6688 分钟前
0基础开发学习python工具_____用 Python + Pygame 打造绚丽烟花秀 轻松上手体验
开发语言·python·学习·pygame
nervermore99018 分钟前
2.6 测试
python
EZ_Python26 分钟前
告别WPS会员!用Python自制电子发票批量打印排版工具
python·自动化
写文章的大米28 分钟前
1 分钟读懂:Python 装饰器
python
2501_9216494934 分钟前
股指期货 API 入门指南:如何获取实时行情与构建交易系统
python·websocket·金融·区块链·restful
Full Stack Developme1 小时前
Spring Security 与 Apache Shiro 两大安全框架比较
spring boot·python·安全
杰瑞哥哥1 小时前
快速搭建Web前端(streamlit使用指南)
python·信息可视化·web·模型部署