小编Rid*_*azi的帖子

使用 map() 将整数列表转换为字符串

我不明白为什么 python 不允许我使用 map() 函数将整数列表更改为字符串列表。当我尝试在 python shell 中执行它时它工作正常,但当我在脚本中尝试时却没有,我真的很困惑为什么会发生这种情况。这是我的脚本代码:

def DashInsert(str):

    list_int = map(int, list(str))
    list_str = map(str, list_int)

    return list_str 
Run Code Online (Sandbox Code Playgroud)

此外,我知道如果列表已经作为字符串输入,我不需要将列表更改回字符串,但我很好奇为什么 Python 在我将它转换为整数列表后不会让我更改列表。我不断收到“str object is not callable”错误。

python dictionary type-conversion

2
推荐指数
1
解决办法
4338
查看次数

标签 统计

dictionary ×1

python ×1

type-conversion ×1