For optional argument actions, the value of dest is normally inferred from the option strings. ArgumentParser generates the value of dest by taking the first long option string and stripping away the initial -- string. Any internal - characters will be converted to _ characters to make sure the string is a valid attribute name
不幸的是,破折号到下划线的替换对于位置参数(没有前缀
--
)不起作用,比如因此,您应该使用第一个参数
add_argument()
作为属性名,使用metavar
kwarg设置它在帮助中的外观:破折号转换为下划线:
作为indicated in the ^{} docs :
所以你应该使用
args.pm_export
。相关问题 更多 >
编程相关推荐