对于编写程序输入一串以‘’分割的字符串,可以使用 Python 中的 split() 方法来实现。示例代码如下:
string = "hello,world,this,is,a,test"
output = string.split(',')
print(output)
输出结果为:
['hello', 'world', 'this', 'is', 'a', 'test']
其中 split() 方法的参数就是用来分割字符串的字符。
对于编写程序输入一串以‘’分割的字符串,可以使用 Python 中的 split() 方法来实现。示例代码如下:
string = "hello,world,this,is,a,test"
output = string.split(',')
print(output)
输出结果为:
['hello', 'world', 'this', 'is', 'a', 'test']
其中 split() 方法的参数就是用来分割字符串的字符。