I want to save my python to json file, but the thing is, I need to name my json file's name as title's name.
code:
data={
"Title" : title.text,
"Registration": doctor.text,
"Keywords": list2,
"Article": list
}
#title.text="banana"
with open('title.text.json', 'w',encoding='UTF-8') as f:
json.dump(data, f,ensure_ascii=False)
The result I expected: Save it as banana.json
Edit: It works with this
with open('%s.json' % title_tag.text, 'w',encoding='UTF-8') as f:
json.dump(data, f,ensure_ascii=False)