Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我如何设置40为一个变量,让我们说temp哪个即时计算并传递而不是40这种格式字符串:
40
temp
{:<40}.format('aa')
像这样的东西应该工作:
>>> width = 40 >>> '{0:<{width}}'.format('aa', width=width) 'aa '