Answers for "python string get everything after character"

1

get string until character python

s = "first_second"
s.split('_')[0] # Split the string on '_' return the first part. 
>>> 'first'
Posted by: Guest on October-23-2020
0

python extract all characters from string before a character

s1 = "Username: How are you today?"
>>> s1.split(':')
['Username', ' How are you today?']
>>> s1.split(':')[0]
'Username'
Posted by: Guest on November-23-2020

Code answers related to "python string get everything after character"

Python Answers by Framework

Browse Popular Code Answers by Language