# -*- coding: utf-8 -*- #测试下载 __author__ = '上海色宁' import os import requests def download_config_file(): remote_config_file = "http://192.168.43.204:80/k2/huaneng_2_power_1_config.py" r = requests.get(remote_config_file, stream=True) with open("setting1.py",'wb') as f: # 分块写入文件 for chunk in r.iter_content(chunk_size=1024): if chunk: f.write(chunk) f.close() print("request and download config file finished . programe will restarted.") #程序入口 if __name__ == '__main__': download_config_file()