How would I get everything before a : in a string Python

前端 未结 5 1612
囚心锁ツ
囚心锁ツ 2020-11-30 20:45

I am looking for a way to get all of the letters in a string before a : but I have no idea on where to start. Would I use regex? If so how?

string = \"Userna         


        
5条回答
  •  天涯浪人
    2020-11-30 21:34

    partition() may be better then split() for this purpose as it has the better predicable results for situations you have no delimiter or more delimiters.

提交回复
热议问题