Python Basics
Python Advanced
Python Useful References
Python Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM
|
Python String center() Method
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:
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
|
|
|
|