简体   繁体   中英

How to convert string without quotation marks to the python array?

Is it possible in Python to convert a raw string divided by commas, eg

tt0099700,tt0096061,tt0118688,tt0120784

into a Python array/list?

Such string is in loop as a variable row[i] .

Thanks for any help.

Try:

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

Output of new_list :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM