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 center() Method


previous next AddThis Social Bookmark Button


Description:

This method returns centered in a string of length width. Padding is done using the specified fillchar. Default filler is a space.

Syntax:

str.center(width[, fillchar])

Parameters:

Here is the detail of parameters:

  • width: is the total width of the string.

  • fillchar: is the filler character.

Return Value:

It returns centered in a string of length width.

Example:

#!/usr/bin/python

str = "this is string example....wow!!!";

print "str.center(40, 'a') : ", str.center(40, 'a')

This will produce following result:

str.center(40, 'a') :  aaaathis is string example....wow!!!aaaa


previous next Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names