sys.stdin/sys.stdout

调用 print 时候,事实上是调用了 sys.stdout.write(obj+’\n’)

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

这两个语句是等价的。

raw_input(‘Input promption: ‘) 时,事实上是先把提示信息输出,然后捕获输入
这两行语句是等价的:

hi=raw_input('hello? ')

print 'hello? ', #comma to stay in the same line
hi=sys.stdin.readline()[:-1] # -1 to discard the '\n' in input stream

print是对 sys.stdout.write的友好封装,input是对 sys.stdin.readline的友好封装,

猜你喜欢

转载自blog.csdn.net/liutaiyi8/article/details/81389666