python - 在没有空格或换行符的python中打印变量

打印一个没有换行符或空格的变量 python3 通过 print (x,end='') 如何在 python 2.5 中做到这一点

最佳答案

sys.stdout.write (仅)写入不带换行符的字符串,除非指定。

>>> x = 4
>>> print x
4
>>> import sys
>>> sys.stdout.write(str(x)) # you have to str() your variables
4>>> # <- no newline

https://stackoverflow.com/questions/3846801/

相关文章:

ios - iPhone : How to get number from string with

java - 在字符串模板电子邮件中格式化日期

c# - 使用 String.Format 时,如果字符串值不为 null 或为空,是否有一种简单的

Python 浮点格式 - 类似于 "g",但数字更多

forms - 如何在 Laravel 中处理日期输入

c# - DataGridViewCheckBoxColumn : FormatException

vim - 使用 Vim,是否有更有效的方法来根据这个最佳实践来格式化 LaTeX 段落?

xml - 如何使用 gVim 格式化未格式化的 XML 文档?

formatting - JSON.Net 将 XML 序列化为 JSON 驼峰式案例

formatting - Gnuplot 平滑置信区间线而不是误差线