带有变量 python3.6 的居中文本

center text with variable python3.6

首先,我是一般编程的新手,所以这意味着我也是 python 的新手,所以输入缓慢以便我跟上。 我试图将包含用户输入的变量的文本行居中。像这样:

age = input ("How old are you? ")    
print ("{: ^80}".format("You are", (age), "years old."))

我已经尝试了很多我能想到的方法来使它居中阅读整行。 . . 你40岁了。 (当然,假设用户输入 = 40) 没有运气。我做错了什么?

谢谢, 罗伯特

在字符串上使用 .center() 会在字符串两边填充空格。

print('You are {} years old'.format(age).center(80))