AttributeError: 'ArgumentParser' object has no attribute 'add_arguparser'
时间: 2023-11-17 08:04:46 浏览: 26
个错误是因为你在使用 argparse 库时,错误地调用了 `add_arguparser` 方法,而正确的方法应该是 `add_argument`。`add_argument` 方法用于向 ArgumentParser 对象中添加命令行参数。你需要检查你的代码并将 `add_arguparser` 改为 `add_argument`。如果你需要更多帮助,请提供你的代码和完整的错误信息。
相关问题
AttributeError: 'ArgumentParser' object has no attribute 'add_argangcaigument'
这个错误是由于在使用LTP时调用了一个不存在的方法导致的。根据引用\[1\]和引用\[2\]的信息,最新的LTP API中并不包含`init_dict`方法,而是包含了`add_words`方法。所以,你需要将代码中的`init_dict`方法替换为`add_words`方法。具体的代码修改如下:
```python
from ltp import LTP
def add_words(add_words_file):
with open(add_words_file) as f:
words = f.read().splitlines()
ltp_obj = LTP()
ltp_obj.add_words(words)
return ltp_obj
ltp_obj = add_words('words.txt')
ltp_dict = ltp_obj.pipeline(\['负重前行的长江大桥'\])
print(ltp_dict.cws)
```
这样修改后,你应该能够成功运行代码并解决`AttributeError`错误。你可以参考引用\[2\]中的代码示例和引用\[3\]中的官方文档来确保你的代码与最新版本的API一致。
#### 引用[.reference_title]
- *1* *2* *3* [AttributeError: ‘LTP‘ object has no attribute ‘init_dict‘解决方案](https://blog.csdn.net/weixin_43178406/article/details/130220058)[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^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
AttributeError: 'DiGraph' object has no attribute 'add_path'
`AttributeError: 'DiGraph' object has no attribute 'add_path'` 这是一个常见的 Python 错误,通常在尝试对一个对象执行某个方法时发生。在这个错误中,`DiGraph` 是 NetworkX 库中的有向图(Directed Graph)对象,`add_path` 是一个期望的方法,但该对象实际上并没有这个属性。
NetworkX 的 `DiGraph` 类不直接提供 `add_path` 方法,它可能提供了其他类似的功能,如添加路径的边或节点,但不是直接通过 `add_path` 这个名字。`add_path` 方法可能存在于其他库或者 NetworkX 的不同版本中,或者是在特定上下文中自定义的。
相关问题:
1. NetworkX 中有没有类似 `add_path` 的方法用于添加路径?
2. 如何在 NetworkX 的 DiGraph 中正确地添加路径?
3. 如果需要沿特定路径添加边,应该如何操作?
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![7z](https://img-home.csdnimg.cn/images/20210720083312.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)
![](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)