1.使用requests模块获取这个json文件http://java-api.super-yx.com/html/hello.json
import requests
import json
response = requests.get("http://java-api.super-yx.com/html/hello.json")
2.将获取到的json转为dict
3.将dict保存为hello.json文件
#转为字典dict
dc = response.json()
#保存到hello.json文件中
file=open("hello.json","wt")
json.dump(dc,file)
file.close()
4.用文件流写一个copy(src,dst)函数,复制hello.json到A:\hello.json
def copy(src, dst):
file1 = open(src,"rb")
file2 = open(dst,"wb")
file2.write(file1.read())
file1.close()
file2.close()
copy("hello.json","A:/hello.json")