Python - 命令行参数(argparse)

Python - 命令行参数(argparse)



test.py:

import argparse

desc = "【Welcome to get there!】"
parser = argparse.ArgumentParser(description=desc)
parser.add_argument('--lr', type=float, default=0.0001, help='The learning rate')
parser.add_argument('--tc', type=int, default=10, help='The count of training')

args = parser.parse_args()
print("lr = ",args.lr)
print("tc = ",args.tc)

demo.py:

#参数可以被导入

from test import *

print("*lr* = ",args.lr)
print("*tc* = ",args.tc)

 

上一篇:GRS认证Recycled再生材料认证怎么做?如何申请Recycled再生认证GRS?


下一篇:基于netty开发的物联网后台框架一套(支持Jt808交通协议