python - 我想从 python 中的 JSON 文件中获取一个随机对象
问题描述
只想要一个来自 JSON 的随机对象
解决方案
import json
#import json file
filter = "JSON file (*.json)|*.json|All Files (*.*)|*.*||"
filename = rs.OpenFileName("Open JSON File", filter)
#Read JSON data into the datastore variable
if filename:
with open(filename, 'r') as f:
datastore = json.load(f)
Random.choice(datastore)
我希望它有效
推荐阅读
- karate - 运行性能测试时注入配置文件出现问题
- pdf - Microsoft Edge 不使用 src="data:application/pdf;..." 在 iFrame 中显示 PDF
- java - 需要来自对象数组的列表中的映射
- java - 如何在没有反射的情况下正确实现持久 CookieStore?
- c# - 子弹反射(弹跳)未按预期工作
- sas - 在满足某些要求时保持观察
- spring-boot - 即使 DB 已关闭,也启动 Spring-Boot/EclipseLink 应用程序,并在 DB 可用时重新连接
- android - 未找到 Google 插件服务,添加时已存在
- python - 在熊猫中“拆分”行的正确方法
- r - 如何使 xlab 与其在 R 中的表示(条形图)一致