把要输入的参数写成配置文件的方式
# config.json
{
"batch_size": 4,
"bpds_kwargs":
{
"buffer_size": 16,
"buffer_switch_interval": 2800,
"patch_shape": [32, 64, 64]
}
}
读取并输入到代码里
# 配置文件存放地址
path_json = Path(json)
json = globals()["json"]
# 加载配置文件数据
with open(path_json) as json_file:
config = json.load(json_file)
# 生成一个空间存放
args = argparse.Namespace()
args.__dict__.update(config)
# 将参数传入函数中
main(args)
最后
以上就是光亮巨人最近收集整理的关于pycharm利用配置文件实现arg参数输入的全部内容,更多相关pycharm利用配置文件实现arg参数输入内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复