'Namespace' object has no attribute 'model'
时间: 2023-08-05 11:04:06 浏览: 165
引用\[1\]:你遇到的错误是因为参数名称中使用了短线而不是下划线。在使用argparse库时,参数名称应该使用下划线而不是短线。例如,应该使用`save_name`而不是`save-name`。\[1\]
引用\[3\]:另外,你遇到的错误可能是因为参数添加的顺序不正确。在使用argparse库时,应该先创建ArgumentParser对象,然后再添加参数,最后再调用parse_args()方法来解析参数。正确的顺序应该是先创建parser,然后添加参数,再创建args对象,最后调用main函数。\[3\]
综上所述,你需要将参数名称中的短线改为下划线,并确保参数的添加顺序正确,即先创建parser,然后添加参数,最后创建args对象。这样就可以避免出现'Namespace' object has no attribute 'model'的错误了。
#### 引用[.reference_title]
- *1* *2* *3* [argparse.ArgumentParser args AttributeError: ‘Namespace‘ object has no attribute ‘xxx](https://blog.csdn.net/qxqxqzzz/article/details/107367501)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)