Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

python - How do I format a string to create an iterable list?

I have a string containing multiple institutions of the following form:

'Harvard University

Yale University

...

'

Where the collection of institutions are contained in a singular string and each institution is separated by a space of size larger than one. How do I join/format the string so that it can appear in a list like [Harvard University, Yale University,..]?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can do

list_of_institutions = institutions.split("
")

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...