print()

通过输入 help(print) 得到 print 内建函数的参数

Help on built-in function print in module builtins:

print(...)
print(value, ..., sep=' ', end='\n', file=sys.stdout, flush=False) Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.

print() 函数的几个参数:

  • value 是值的意思,可以传出字符串、数字、列表等
  • sep 默认为空格,在打印的时候两个值之间填充空格
  • end 默认是换行,当不想要换行显示的时候可以修改默认值
  • file 表示了 print 和 sys.stdout 的关系,print 函数默认已经是标准化输出
  • flush 是刷新的意思
'''
使用一个循环容易看出效果,分隔符用 123 代替,默认的换行改成了制表符,可以看到打印之后光标没有到下一行
'''
>>> for i in range(2):
print("hello", "world", sep='123', end='\t') hello123world hello123world >>>

这里有一篇有趣的文章,通过调整 flush 参数实现动态图的效果python的print(flush=True)实现动态loading......效果

【Python】【Head First Python】【chapter1】2 - sys.stdout 和 print 的区别的更多相关文章

  1. python 以标准输出(sys.stdout)为例,看python的标准输入、标准错误输出

    看了一个博客,挺不错的.http://www.cnblogs.com/turtle-fly/p/3280519.html 标准输出(sys.stdout)对应的操作就是print(打印)了,标准输入( ...

  2. Python 标准输出 sys.stdout 重定向(转)

    add by zhj: 其实很少使用sys.stdout,之前django的manage.py命令的源码中使用了sys.stdout和sys.stderr,所以专门查了一下 这两个命令与print的区 ...

  3. python之sys.stdout、sys.stdin

    转自:http://www.cnblogs.com/turtle-fly/p/3280519.html 本文环境:Python 2.7  使用 print obj 而非 print(obj) sys. ...

  4. Python 标准输出 sys.stdout 重定向

    本文环境:Python 2.7 使用 print obj 而非 print(obj) 一些背景 sys.stdout 与 print 当我们在 Python 中打印对象调用 print obj 时候, ...

  5. python中sys.stdout、sys.stdin

    如果需要更好的控制输出,而print不能满足需求,sys.stdout,sys.stdin,sys.stderr就是你需要的. 1. sys.stdout与print: 在python中调用print ...

  6. 【python】print · sys.stdout · sys.stderr

    参考文档 Python重定向标准输入.标准输出和标准错误 http://blog.csdn.net/lanbing510/article/details/8487997 python重定向sys.st ...

  7. python重定向sys.stdin、sys.stdout和sys.stderr

    转自:https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入.标准输出和错误输出. 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使 ...

  8. python之sys.stdout、sys.stdin以及设置打印到日志文件等

    转自:https://www.cnblogs.com/BigFishFly/p/6622784.html python之sys.stdout.sys.stdin 转自:http://www.cnblo ...

  9. python sys.stdin、sys.stdout和sys.stderr

    学习并转载自  https://www.cnblogs.com/guyuyuan/p/6885448.html 标准输入:一般是键盘.stdin对象为解释器提供输入字符流,一般使用raw_input( ...

随机推荐

  1. jQuery的一些选择器

    一.基本选择器 1. id选择器(指定id元素) 将id="one"的元素背景色设置为黑色.(id选择器返单个元素) $(document).ready(function () { ...

  2. bash编程,while嵌套case语句, file不能判断文件存在与否

    写一个脚本, 完成如下要求 (1)脚本可接受参数 : start, stop, restart, status, (2)如果参数非非法, 提示使用格式后报错退出; (3)如果是start, 则创建/t ...

  3. tf.cast(ndarray,dtype)

    转化为指定的类型,一般是将bool类型转化为其他的数据类型,例如:tf.float32

  4. NodeJS学习笔记 (18)基础调试-console(ok)

    模块概览 console模块提供了基础的调试功能.使用很简单,常用的API主要有 console.log().console.error(). 此外,可以基于Console类,方便的扩展出自己的con ...

  5. js cookie 页面倒计时

    疯了啦 写了一篇没有保存需求:页面倒计时 只从第一次加购开始公共方法cookie的设置 获取function getCookie(c_name){ if (document.cookie.length ...

  6. Fans同学已死,终年24岁

    亲爱的同学们,朋友们,QQ好友. 告诉大家一个悲剧:Fans同学已死,终年24岁. 马甲变迁 正式告诉大家一个消息,我的ID"Fans同学"正在退出"历史舞台" ...

  7. Project Euler:Problem 58 Spiral primes

    Starting with 1 and spiralling anticlockwise in the following way, a square spiral with side length ...

  8. Ubuntu 经常使用软件安装

    Chromium 14.04+ FlashPlayer 原理 就是安装一个flash插件而已啊,网上都没有详解. 我们首先在浏览器地址栏输入chrome://plugins, 全部插件都会展示出来了. ...

  9. java-proxool 异常

    使用 proxool,JDBC连接池,进行批量运行的时候遇到异常: The Thread responsible was named 'Thread-32′, but the last SQL it ...

  10. POJ 1887 Testingthe CATCHER (LIS:最长下降子序列)

    POJ 1887Testingthe CATCHER (LIS:最长下降子序列) http://poj.org/problem?id=3903 题意: 给你一个长度为n (n<=200000) ...