python读取数据怎么去掉逗号

2024-04-03

要去掉数据中的逗号,可以使用字符串的replace()方法来替换逗号为空格或空字符串。以下是一个示例代码:

# 读取数据
data = "1,2,3,4,5"

# 去掉逗号
data_without_comma = data.replace(",", "")

print(data_without_comma)

上述代码将会输出:12345。这样就去掉了数据中的逗号。

《python读取数据怎么去掉逗号.doc》

下载本文的Word格式文档,以方便收藏与打印。