python 使用指定字符分割字符串
可以使用 Python 的 split() 方法来分割字符串,并指定分隔符。
例如,如果要使用逗号作为分隔符分割字符串,可以使用以下代码:
my_string = "apple,banana,orange"
split_string = my_string.split(",")
print(split_string)
输出结果为:
['apple', 'banana', 'orange']
在这个例子中,split() 方法使用逗号作为分隔符来分割字符串,并将分割后的子字符串存储在列表中。
原文地址: https://www.cveoy.top/t/topic/ftdv 著作权归作者所有。请勿转载和采集!