我是靠谱客的博主 光亮巨人,这篇文章主要介绍pycharm利用配置文件实现arg参数输入,现在分享给大家,希望可以做个参考。

把要输入的参数写成配置文件的方式

复制代码
1
2
3
4
5
6
7
8
9
10
11
# config.json { "batch_size": 4, "bpds_kwargs": { "buffer_size": 16, "buffer_switch_interval": 2800, "patch_shape": [32, 64, 64] } }

读取并输入到代码里

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
# 配置文件存放地址 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参数输入内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(73)

评论列表共有 0 条评论

立即
投稿
返回
顶部