TypeError: translate() takes exactly one argument (2 given)
时间: 2024-05-20 18:12:56 浏览: 11
这错误通常表示你在调用 `translate()` 函数时传递了多余的参数。`translate()` 函数只接受一个参数,但是你传递了两个参数。
请检查你的代码,确认你在调用 `translate()` 函数时只传递了一个参数。如果你需要传递多个参数,可以将它们封装到一个列表或字典中,然后将整个列表或字典作为 `translate()` 函数的参数传递。
相关问题
TypeError: len() takes exactly one argument (2 given)
This error message is indicating that the `len()` function was given two arguments, but it expected only one.
Here's an example of how this error might occur:
```
my_list = [1, 2, 3]
print(len(my_list, 2))
```
In this code, we're trying to call the `len()` function with two arguments: `my_list` and `2`. However, `len()` expects only one argument (the object whose length we want to find), so it raises a `TypeError`.
To fix this error, we need to pass only one argument to `len()`, like this:
```
my_list = [1, 2, 3]
print(len(my_list))
```
Now, `len()` is receiving only one argument (`my_list`), so it knows what to do and returns the correct length of the list (which is 3, in this case).
TypeError: append() takes exactly one argument (2 given)
这个错误通常是由于在使用append()方法时传递了多个参数导致的。请确保在调用append()方法时只传递了一个参数,例如:
```
my_list = [1, 2, 3]
my_list.append(4)
print(my_list) # 输出 [1, 2, 3, 4]
```
如果您能提供更多的上下文或代码,我可以更具体地帮助您解决问题。
相关推荐
![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)
![](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)