python:执行一个命令行N次,,经常希望可以执行一个
python:执行一个命令行N次,,经常希望可以执行一个
经常希望可以执行一个命令行N次。。。windows下没有现成的工具(有?推荐给我!)
用python写一个。。。
#!/usr/bin/evn python#coding: utf-8"""times.pyrun a command line for n times"""import os import sysimport stringif __name__ == "__main__": n = 1 cmd = "" if len(sys.argv) >= 3: n = int(sys.argv[1]) cmd = string.join(sys.argv[2:], ‘ ‘) else: print ‘‘‘error command lineUseage: times n "command line"‘‘‘ exit(1) for x in range(n): os.system(cmd)
实现效果
C:\Users\hydon>times 10 echo hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.hello world.
python:执行一个命令行N次
相关内容
- 暂无相关文章
评论关闭