简体   繁体   中英

In Python how to convert a string into list

What command in python can be used to make the string ST = “WORK,IS,DONE” a list [“WORK”,”IS”,”DONE”]?

I am trying this but its not working

ST = txt.split(",")

print(ST)

Looks like you have the string defined under ST and not txt, which appears to be the issue.

st = "WORK,IS,DONE"
st = st.split(sep=",")
print(st)

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