Copyright © tutorialspoint.com
This method checks whether string starts with str, optionally restricting the matching with the given indices start and end.
str.startswith(str, beg=0,end=len(string)); |
Here is the detail of parameters:
str: string to be checked
beg: optional parameter to set start index of the matching boundary.
end: optional parameter to set end index of the matching boundary.
It returns true if found matching string otherwise false.
#!/usr/bin/python str = "this is string example....wow!!!"; print str.startswith( 'this' ); print str.startswith( 'is', 2, 4 ); print str.startswith( 'this', 2, 4 ); |
This will produce following result:
True True False |
Copyright © tutorialspoint.com