Python running 使用参数

Python running 使用参数

Use command line to transfer args into code

i. sys.argv

	import sys 
	gpus = sys.argv[1] 
	batch_size = sys.argv[2] 
	print gpus 
	print batch_size

ii. Argparse

	import argparse 
	parser = argparse.ArgumentParser(description='manual to this script') 
	parser.add_argument('--gpus', type=str, default = None) 
	parser.add_argument('--batch-size', type=int, default=32) 
	args = parser.parse_args()
	print args.gpus 
	print args.batch_size

https://blog.csdn.net/weixin_35653315/article/details/72886718

posted @ 2022-06-27 20:05  xiaoxuxli  阅读(103)  评论(0编辑  收藏  举报