-1
我想用子流程導出多個txt文件。用子流程導出多個文件
ip_address = ['172.16.{}.{}'.format(rack_number, box_number) for box_number in stb_list]
ip_address = ['10.10.8.89'] # Testing for single ip
# def planner_events_info():
#Connect to Boxes
if len(ip_address) > 0:
for ip in ip_address:
action = 'FullExport'
menu_action = 'all'
arg_list = [('C:\\Users\\yke01\\Documents\\StormTest\\Scripts\\Completed'
'\\Utils\\UPNP_Client_Cmd_Line.py')]
arg_list.append(' --action=')
arg_list.append(action)
arg_list.append(' --ip=')
arg_list.append(ip)
arg_list.append(' --menu=')
arg_list.append(menu_action)
x = subprocess.Popen(arg_list, shell=True)
# print arg_list
with open("output.txt", "w+") as output:
subprocess.call(["python", arg_list], stdout=output)
使用單個IP地址我可以導出output.txt。我正在爲最多16個不同的ips寫腳本。
ip_address = ['172.16.1.1, 172.16.1.2, 172.16.1.3, 172.16.1.4, ]
例如,對於上述ip地址,我想導出4個txt文件。任何幫助將不勝感激。!
對於每個ip,您使用的是同一個文件「output.txt」。更改每個ip的'output.txt'的名稱以寫入不同的文件。 –