I have a file with colon and semi-colon delimited string elements. They are email addresses formatted as such:
Tony Stark, <ironman@stark-tesla.com>; Clark Kent, <Ckent1@dailyplanet.com>; Peter Parker, <pparker1@spidy.com>; etc.
What I would like to do is separate each email using it's semi-colon and place it on it's own line or row:
eg
Tony Stark, <ironman@stark-tesla.com>
Clark Kent, <Ckent1@dailyplanet.com>
Peter Parker, <pparker1@spidy.com>
What is the most efficient way of accomplishing this?
Thanks
try
string="Tony Stark, <ironman@stark-tesla.com>; Clark Kent, <Ckent1@dailyplanet.com>; Peter Parker, <pparker1@spidy.com>"
for i in string.split("; "):
print(i)
the.split method on strings returns an array containing the string split by the separator. The for loop loops through the split string and prints out each one on it's own line.
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.