您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在python中打印没有换行的语句?

在python中打印没有换行的语句?

这可以用轻松完成打印() 函数 与 。

for i in x:
  print(i, end="")  # substitute the null-string in place of newline

会给你

......

在 您可以通过以下方式使用该print()函数

from __future__ import print_function

作为源文件中的 第一条 语句。

print()文档所述

Old: print x,           # Trailing comma suppresses newline
New: print(x, end=" ")  # Appends a space instead of a newline

请注意,这类似于我最近回答的问题http://codingdict.com/questions/193853),其中包含一些有关此print()功能的其他信息(如果您感到好奇)。

python 2022/1/1 18:26:16 有177人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶