我想从每个组中编写不同的文本文件;我该怎么做?目前它正在将所有内容写入一个txt文件。
data = json.loads(output)
print "===========================Example 1======================================="
for issue in data["issues"]:
print issue ['key'], issue['fields']['summary']
data = json.loads(output1)
print"======================Example 2===================================="
for issue in data["issues"]:
print issue ['key'], issue['fields']['summary']
data = json.loads(output2)
print"====================== Example 3===================================="
for issue in data["issues"]:
print issue ['key'], issue['fields']['summary']
data = json.loads(output3)
print"======================Example 4===================================="
for issue in data["issues"]:
print issue ['key'], issue['fields']['summary']
data = json.loads(output4)
print"======================Example 5===================================="
for issue in data["issues"]:
print issue ['key'], issue['fields']['summary']
Thia 是我解决这个问题的方法:
for issue in data["issues"]:
f.write(issue ['key'])
f.write(issue['fields']['summary'])
f.write('\n')
它将每件事都写在一个列表和每一行下的单独文件中。