Python学习:输入输出重定向

来源:互联网 发布:mac系统顿号怎么打 编辑:程序博客网 时间:2024/05/21 01:28

Python代码:

import oscmd = input('cmd:')os.system(cmd)

控制台代码:


(输出到文件中:同名会覆盖)

F:\qianfeng\yicheng\test1>python 输入输出重定向.py >ipconfig.txt
ipconfig


(输出到文件中:同名不会覆盖)

F:\qianfeng\yicheng\test1>python 输入输出重定向.py >>ipconfig.txt
netstat


(从文件读入)

F:\qianfeng\yicheng\test1>python 输入输出重定向.py <tasklist.txt