split()

All String methods

split() returns a list after breaking a string using delimiter and max value
my_str.split(delimiter,max_value) 
delimiter : (default is space), required, to be used to break the string
max_value : optional , the number of elements in output plus one. Default value is -1 so it includes all occurance.
my_list="'Alex','Ronald','John'"
my_list=my_list.split(',')
print(my_list)

my_list="'Alex','Ronald','John'"
my_list=my_list.split(',',1)
print(my_list)
output
["'Alex'", "'Ronald'", "'John'"]
["'Alex'", "'Ronald','John'"]
By using rsplit() in place of split(), the output will change like this. ( diference betweeen rsplit() and split() )
["'Alex'", "'Ronald'", "'John'"]
["'Alex','Ronald'", "'John'"]
All String methods


Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here





    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer