[Tutor] Question About the .format Method.
Alan Gauld
alan.gauld at yahoo.co.uk
Thu Nov 10 04:20:10 EST 2016
On 09/11/16 22:30, Bryon Adams wrote:
> Hello,
> Working on a simple function to get an IP address and make it look
> pretty for the PyNet course. I'm wondering if there's way to evenly
> space text with the string.format() method similar to how I'm doing it
> with the % operator.
Yes, read section 6.1.3 of the documentation
https://docs.python.org/3/library/string.html#formatstrings
You can do everything that % formatting can do, and some more.
See the examples in section 6.1.3.2
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list