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)  #测试用
相关推荐
2501_941111511 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
bitbrowser2 小时前
哪些指纹浏览器支持模拟SSL指纹
网络·python·网络协议·ssl
limenga1023 小时前
TensorFlow Keras:快速搭建神经网络模型
人工智能·python·深度学习·神经网络·机器学习·tensorflow
心软小念4 小时前
用Python requests库玩转接口自动化测试!测试工程师的实战秘籍
java·开发语言·python
sanggou5 小时前
【Python爬虫】手把手教你从零开始写爬虫,小白也能轻松学会!(附完整源码)
开发语言·爬虫·python
geng_zhaoying6 小时前
在VPython中使用向量计算3D物体移动
python·3d·vpython
半tour费6 小时前
TextCNN-NPU移植与性能优化实战
python·深度学习·分类·cnn·华为云
普通网友6 小时前
使用Flask快速搭建轻量级Web应用
jvm·数据库·python
百锦再6 小时前
第17章 模式与匹配
开发语言·后端·python·rust·django·内存·抽象
普通网友7 小时前
Python函数定义与调用:编写可重用代码的基石
jvm·数据库·python