在Unix上使用os.system命令的Python Counter Loop

时间:2017-11-12 08:45:11

标签: linux python-2.7 unix

我有一个简单的计数器循环,在使用'print'

时工作正常
import time

def screenshot(get_name):
    print('Screenshoting {0}').format(get_name)
    time.sleep(1)
counter = 0
while True:
    screenshot(counter)
    counter = counter + 1

但是当我尝试将它应用到os.system(“Command”)时它不起作用?

import time

def screenshot(get_name):
    os.system("screencapture ~/Desktop/test/screenshot{0}.jpg").format(get_name)
    time.sleep(1)
counter = 0
while True:
    screenshot(counter)
    counter = counter + 1

0 个答案:

没有答案