ct_dishes = collections.OrderedDict()
dict_dishes['title'] = str(title).replace("\n", "").replace(" ", "")
dict_dishes['flavours'] = str(flavours).replace("\n", "").replace(" ", "")
dict_dishes['steps'] = str(steps).replace("\n", "").replace(" ", "")
dict_dishes_total = [dict_dishes]
# print(dict_dishes_total)
self.write_content(dict_dishes_total)
def write_content(self,dict_dishes):
print('开始写入')
content = json.dumps(dict_dishes)
with open('receipes.json', 'w') as f:
f.write(content)
写入的结果是
[
{
"title": "\u51c9\u62cc\u571f\u8c46\u4e1d\uff0c\u723d\u53e3\u5f00\u80c3",
"flavours": "\u571f\u8c462\u4e2a\u80e1\u841d\u535c\u534a\u6839\u5c16\u69121\u4e2a\u849c5-6\u74e3\u5e72\u8fa3\u69123-4\u4e2a\u82b1\u69127-8\u7c92\u5473\u6781\u9c9c\uff08\u751f\u62bd\uff091\u52fa\u9999\u918b1.5-2\u52fa\u76d0\u6839\u636e\u53e3\u5473\u9002\u91cf\u9e21\u7cbe\u5c0f\u534a\u52fa\u767d\u7cd61\u52fa",
"steps": "\u571f\u8c46\u5207\u4e1d\uff08\u64e6\u4e1d\uff09\uff0c\u7528\u6c34\u6ce1\u4e00\u4e0b\u6362\u6c34\uff0c\u591a\u51b2\u6d17\u51e0\u6b21\uff0c\u76f4\u5230\u6ce1\u571f\u8c46\u4e1d\u7684\u6c34\u53d8\u6e05\u6f88\uff0c\u628a\u6dc0\u7c89\u51b2\u6389\u571f\u8c46\u4e1d\u624d\u4f1a\u6bd4\u8f83\u6e05\u8106\u723d\u53e3\u80e1\u841d\u535c\u5207\u4e1d\uff08\u64e6\u4e1d\uff09\u9505\u91cc\u70e7\u6c34\uff0c\u6c34\u5f00\u4ee5\u540e\u5012\u5165\u571f\u8c46\u4e1d\u548c\u80e1\u841d\u535c\u4e1d\uff0c90\u79d2\u635e\u51fa\u6b64\u65f6\u662f\u6700\u8106\u7684\uff0c\u6700\u957f\u4e0d\u8981\u8d85\u8fc7\u4e24\u5206\u949f\u3002\u5982\u679c\u559c\u6b22\u751f\u5403\u80e1\u841d\u535c\u53ea\u712f\u571f\u8c46\u4e1d\u5c31\u884c\u4e86\u635e\u51fa\u4ee5\u540e\u7528\u51b7\u6c34\u51b2\u6d17\u4e09\u6b21\u81f3\u5b8c\u5168\u51b7\u5374\u5c16\u6912\u5207\u4e1d\uff0c\u6df7\u5408\u5728\u4e00\u8d77\u653e\u5728\u4e2a\u5927\u7897\u91cc\uff5e\u7897\u4e0d\u591f\u5927\u76f4\u63a5\u653e\u9505\u91cchh\u4e00\u52fa\u5473\u6781\u9c9c\uff08\u751f\u62bd\uff09\uff0c\u4e24\u52fa\u9999\u918b\uff0c\u5982\u679c\u662f\u9648\u918b\u653e\u4e00\u52fa\u6216\u8005\u4e00\u52fa\u534a\u5c31\u53ef\u4ee5\u4e86\uff0c\u9002\u91cf\u76d0\uff0c\u76d0\u5148\u5c11\u653e\u5c1d\u5c1d\u5473\u9053\u518d\u52a0\uff0c\u4e0d\u8981\u52a0\u591a\uff0c\u4e00\u52fa\u767d\u7cd6\u63d0\u9c9c\uff0c\u5c0f\u534a\u52fa\u9e21\u7cbe\uff0c6\u74e3\u849c\u5241\u6210\u6ce5\uff0c\u62cc\u5300\u70ed\u9505\u70e7\u6cb9\uff0c\u5c0f\u706b\uff0c\u51c9\u6cb9\u52a0\u5165\u5e72\u8fa3\u6912\u548c\u82b1\u6912\u7c92\uff0c\u7231\u5403\u8fa3\u7684\u53ef\u4ee5\u591a\u653e\u5e72\u8fa3\u6912\uff0c\u628a\u5e72\u8fa3\u6912\u5207\u6bb5\u518d\u653e\u4f1a\u66f4\u6709\u5473\u513f\uff5e\u5168\u7a0b\u5c0f\u706b\uff0c\u51fa\u9999\u5473\u4ee5\u540e\u7528\u5e72\u71e5\u7684\u94f2\u5b50\u7ffb\u4e00\u4e0b\u518d\u8fc7\u5341\u51e0\u79d2\u5373\u53ef\u6d47\u5230\u571f\u8c46\u4e1d\u4e0a\u6700\u540e\u518d\u52a0\u4e00\u70b9\u70b9\u9999\u6cb9\uff0c\u62cc\u5300\uff0c\u8d85\u7ea7\u597d\u5403\uff01\u6211\u89c9\u5f97\u53ef\u4ee5\u518d\u52a0\u70b9\u9999\u83dc\u4f46\u6211\u5bb6\u91cc\u6ca1\u5566\u5c31\u6ca1\u52a0\uff5e"
}
]
© 2021 Python学习网 苏ICP备2021003149号-1