'list' object has no attribute 'join'
时间: 2023-10-02 09:10:25 浏览: 42
The error "'list' object has no attribute 'join'" occurs when you try to use the join() method on a list object. The join() method is used to concatenate elements of a sequence (such as a list) into a string using a specified delimiter.
However, the join() method is not available for lists in Python. It is only available for strings. To concatenate elements of a list into a string, you can use the join() method on a string with the list as an argument.
Here's an example:
```
my_list = ['Hello', 'World', '!']
delimiter = ' '
result = delimiter.join(my_list) # joining the elements of the list with a space delimiter
print(result) # Output: Hello World !
```
In this example, we use the join() method on the string delimiter with the list my_list as an argument. The elements of my_list are concatenated into a single string separated by the delimiter.