简体   繁体   中英

How to remove space (before or) after comma from a string?

How do I remove whitespace before or after comma? I have tried split(), but I want the result be a string as well.

Eg

string1 = "tree one two, true op op,blue io op" result = "tree one two,true op op,blue io op"

lstrip() will remove left blank spaces, rstrip() will remove right blank spaces, strip() will remove all blank spaces.

By the looks of it, lstrip() is what you're after.

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