Python 官方文档:入门教程 => 点击学习
一、环境以及背景 winows10 + python2.7 + python3.5 需要使用Python2.7 中的print并且不换行二、使用方法 1. 在结尾添加一个逗号 print "hello wor
一、环境以及背景
winows10 + python2.7 + python3.5
需要使用Python2.7 中的print并且不换行
二、使用方法
1. 在结尾添加一个逗号
print "hello world",
问题: 在输出结果后会多一个空格,这个空格把我坑了
2. 使用sys模块
import sys
sys.stdout.write("hello world")
sys.stdout.flush()
3. 使用python 3.x版本的print
3.x版本 中的print函数增加了一个end参数, 默认值为end='\n'
print ("hello world", end='')
--结束END--
本文标题: python print实现不换行打印
本文链接: https://www.lsjlt.com/news/189071.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0