简体   繁体   中英

How can I customize the format of Python output?

I know basically nothing about python (I did know about it before but never took the time to try it out). I've started using python because I'm doing an A level course in computer science.

I wanted to know how to center align the output ?

What I've done to "center" align is:

print ("------(<< the spaces didnt show up in post, so i used "-"'s)How long have you been alive")

But I feel that its the wrong technique to use, how do I do it properly? Also, is it possible to change the colours of the output/runned view for example have a title black and other writing blue, and the background yellow.

The method center() 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])

You could refer to the links below.

http://www.tutorialspoint.com/python/string_center.htm

https://docs.python.org/2/library/string.html#string.center

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM