【发布时间】:2019-09-21 18:14:37
【问题描述】:
代码
import json
from faker import Faker
import random
from random import randint
fake = Faker('en_US')
for _ in range(1):
sds = {
"id": "AB-asdfaf",
"body": fake.sentence(),
"time": fake.ean(),
"hash": fake.ean(),
"id1": fake.ean(),
"user_id": "asdasdas",
"id3": "test1"
}
print(sds)
我得到的输出是单引号''。我需要得到 json ijn 双引号
输出:
'body': 'Throughout third tough will PM time treat.'
我需要的输出:
"body": "Throughout third tough will PM time treat."
【问题讨论】:
-
这只是python的表示,你不用担心。你有什么问题?
-
将其写入文件 - 您不必更改引号。
-
将打印数百个随机数据并发布到其他地方。但它只会接受 " " 而不是 ' '
-
没关系 -
print()使用单个配额在屏幕上显示它,但模块json将使用双配额写入它。 -
在 jupyter 中尝试过相同的 ' ' 正在返回
标签: python json python-3.x faker