当前位置:网站首页>Argparse command line passes list type parameter
Argparse command line passes list type parameter
2022-06-13 01:04:00 【kaims】
Error model ( Not recommended , It is not convenient to transfer parameters dynamically ):
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--alpha', type=list, default=[0.35, 0.25, 0.40])
args = parser.parse_args()
if __name__ == '__main__':
print(args.alpha)

Correct example 1 :
import argparse
parser = argparse.ArgumentParser()
## nargs='+' Accept 1 Two or more parameters ,
## nargs='*' Accept zero or more
parser.add_argument('--list', nargs='+', help='<Required> Set flag', required=True)
args = parser.parse_args()
if __name__ == '__main__':
print(args.list)
The parameters passed in at runtime are separated by spaces , The operation results are as follows :
Correct example 2 :
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--ll', action='append', help='<Required> Set flag', required=True)
args = parser.parse_args()
if __name__ == '__main__':
print(args.ll)
Running examples and results :
reference :
https://zhuanlan.zhihu.com/p/258446208
边栏推荐
- Et5.0 simply transform referencecollectorieditor
- Common skills of quantitative investment - index part 2: detailed explanation of BOL (Bollinger line) index, its code implementation and drawing
- How many rounds of deep learning training? How many iterations?
- [imx6ull] video monitoring project (USB camera +ffmepeg)
- Several categories of software testing are clear at a glance
- Canvas random bubbling background
- Continue when the condition is not asked, execute the parameter you compare
- Today's sleep quality record 74 points
- Et5.0 value type generation
- pytorch是什么?解释pytorch的基本概念
猜你喜欢

Jenkins continuous integration operation

Plusieurs catégories de tests logiciels sont claires à première vue

軟件測試的幾種分類,一看就明了

Undirected graph -- computing the degree of a node in compressed storage

Illustrator tutorial, how to add dashes and arrows in illustrator?

Breadth first search for node editor runtime traversal

Introduction to ROS from introduction to mastery (zero) tutorial

三栏简约typecho主题Lanstar/蓝星typecho主题

gpu加速pytorch能用吗?
![[JS] battle chess](/img/1f/83ca6bcb000a5567dc6d3b72463ff8.jpg)
[JS] battle chess
随机推荐
Binary tree traversal - recursive and iterative templates
ArrayList underlying source code
深度学习训练多少轮?迭代多少次?
Bubble sort - alternate sort at both ends
spiral matrix visit Search a 2D Matrix
Quick power explanation
[backtrader source code analysis 7] analysis of the functions for calculating mean value, variance and standard deviation in mathsupport in backtrader (with low gold content)
Three threads print digital demo alternately
生物解锁--指纹录入流程
[JS component] floating text
. The way to prove the effect of throwing exceptions on performance in. Net core
Kotlin coroutine suspend function suspend keyword
Pipeline pipeline project construction
Can GPU acceleration pytorch work?
Androi天氣
Jenkins continuous integration operation
sort
[North Asia server data recovery] data recovery case of Hyper-V service paralysis caused by virtual machine file loss
Leetcode-11- container with the most water (medium)
軟件測試的幾種分類,一看就明了