15 lines
596 B
Python
15 lines
596 B
Python
import json
|
|
|
|
def writ_json_file(root_folder_path,sart_index_num, file_total_count,target_ip,start_listen_port) :
|
|
for i,v in enumerate(range(sart_index_num, sart_index_num + file_total_count)):
|
|
# 定义一个json
|
|
port = str(start_listen_port + i)
|
|
target = target_ip + ":" + port
|
|
json_config = {
|
|
"server": target,
|
|
"port": ":"+ port,
|
|
}
|
|
print(json_config)
|
|
# 写对应文件
|
|
with open(f'{root_folder_path}/{v}.json', 'w', encoding='utf-8') as json_file:
|
|
json.dump(json_config, json_file, indent=4) |