简体   繁体   中英

How to split this Python String to get meaningful output?

Hi everyone, I have this String :

 "ParsedText": "180 Grade IV\r\n\Class VIII Pass\r\nwww.forbes.com, Since 2012\r\n"

I am trying to remove all \\r\\n and get everyword inside a list . This is what I meant :

[180 Grade IV, Class VIII Pass, www.forbes.com, Since 2012]

How can this be achieved ? Please provide your valuable ideas. Thanks

try this

code

string="180 Grade IV\r\nClass VIII Pass\r\nwww.forbes.com, Since 2012\r\n"
print(string.split('\r\n'))

output

['180 Grade IV', '\\Class VIII Pass', 'www.forbes.com, Since 2012', '']

did you mean like this??

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