25. python --sys.stdout

标准输出(sys.stdout)对应的操作就是print(打印)了,

标准输入(sys.stdin)则对应input(接收输入)操作,

标准错误输出和标准输出类似也是print(打印)

当我们使用print(obj)在console上打印对象的时候,实质上调用的是sys.stdout.write(obj+'\n'),print在打印时会自动加个换行符,以下两行等价:

 
  1. sys.stdout.write('hello'+'\n')

  2. print 'hello'

猜你喜欢

转载自blog.csdn.net/lzmlc0109/article/details/87972060