我有以下文件,它调用一个端点并将结果保存到json文件中,以便对我的算法执行基准测试。
import requests
import json
import simplejson
r = requests.get('http://localhost:5000/get_jobs/accurate,detail%20oriented,n mbers,finance,analyst,optimistic,emotional%20intelligence,positive,calm,resilient,stable,committed,competitive,ambitious,determined,targets,goal-oriented,quick%20learner').json()
f = open('ProfileA.json', 'w')
simplejson.dump({'this is a test on Profile A with the following words: accurate,detail%20oriented,numbers,finance,analyst,optimistic,emotional%20intelligence,positive,calm,resilient,stable,committed,competitive,ambitious,determined,targets,goal-oriented,quick%20learner' : r}, f,sort_keys = True, indent = 4)
f.close()
我想知道python中是否有任何方法可以简单地用随机字符串生成器复制文件。
我在想办法,比如说一个正则表达式,它可以提取字符串,如果它发现这个字符串会用一个新的字符串写入另一个文件,但是听起来效率很低。