sys.stdin.read() 用于处理标准输入,也就是让用户通过键盘进行输入
sys.stdout.write() 用户处理标准输出,也就是把输入的数据输出到屏幕
#!/usr/bin/env python #-*- coding:utf-8 -*- import sys data = sys.stdin.read() # 接收标准输入 sys.stdout.write(data) # 打印标准输出
[root@localhost ~]$ python 1.py hello world <--- 执行该脚本之后,光标会停在这里等待用户输入,这里我们输入 hello world,然后按 Ctrl + D 可以结束输入 hello world <--- 这里会打印我们输入的数据