Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python String startswith() Method


previous next AddThis Social Bookmark Button


Description:

This method checks whether string starts with str, optionally restricting the matching with the given indices start and end.

Syntax:

str.startswith(str, beg=0,end=len(string));

Parameters:

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.

Return Value:

It returns true if found matching string otherwise false.

Example:

#!/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


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names