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)  #测试用
相关推荐
许彰午15 分钟前
77_Python数据清洗实战技巧
开发语言·python
江华森37 分钟前
04-python-面向对象
开发语言·python
梦帮科技39 分钟前
基于EVM架构的Web3音频确权与RNS Token智能合约设计深度解析
人工智能·python·架构·web3·区块链·音视频·智能合约
AI行业学习40 分钟前
Notepad++ 官方纯净下载+完整安装教程(Windows)【2026.7.5】
开发语言·windows·python·前端框架·html·notepad++
伏 念44 分钟前
Hermes Agent
python
江华森1 小时前
从零构建搜索引擎:Python 异步爬虫 + 倒排索引 + Sanic 前后端实战
python
2401_868534781 小时前
网络规划设计师学习笔记
python·计算机网络
安然无虞1 小时前
Python自动化测试·Selenium操控元素的方法
python·selenium·测试工具
浩瀚之水_csdn1 小时前
Python 3 网络编程详解:从原理到实战
开发语言·网络·python
满怀冰雪1 小时前
24_中间件系统源码分析_Middleware链的洋葱模型与异常处理
人工智能·python·中间件·langchain