标签:
经常希望可以执行一个命令行N次。。。windows下没有现成的工具(有?推荐给我!)
用python写一个。。。
#!/usr/bin/evn python #coding: utf-8 """ times.py run a command line for n times """ import os import sys import string if __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 line Useage: 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.
标签:
原文地址:http://www.cnblogs.com/hydonlee/p/5474682.html