python map(str,)
时间: 2024-02-08 15:32:21 浏览: 50
Python建立Map写Excel表实例解析
The `map()` function in Python applies a given function to each item of an iterable and returns a new iterable with the results. The `str()` function is a built-in Python function that converts an object to a string.
Therefore, `map(str, iterable)` will convert each item in the iterable to a string.
For example:
```
numbers = [1, 2, 3, 4]
string_numbers = map(str, numbers)
print(list(string_numbers))
# Output: ['1', '2', '3', '4']
```
In this example, `map(str, numbers)` returns a new iterable where each number in the `numbers` list is converted to a string. The `list()` function is used to convert the iterable to a list so that we can print it.
阅读全文