如何将不带引号的字符串转换为python数组?

时间:2019-05-04 13:53:24

标签: python csv

在Python中是否可以转换以逗号分隔的原始字符串,例如

tt0099700,tt0096061,tt0118688,tt0120784

进入Python数组/列表?

这种字符串作为变量row[i]循环出现。

感谢您的帮助。

1 个答案:

答案 0 :(得分:5)

尝试:

input_list = 'tt0099700,tt0096061,tt0118688,tt0120784'
new_list = input_list.split(',')

new_list的输出:

['tt0099700', 'tt0096061', 'tt0118688', 'tt0120784']