我尝试添加间距在串两者之间的文本对齐瓦尔不使用“”这样做Python的间距和对齐字符串
试图让文本看起来像这样,在第二列对齐。
Location: 10-10-10-10 Revision: 1
District: Tower Date: May 16, 2012
User: LOD Time: 10:15
目前已将其编码这样的,只是用空格...
"Location: " + Location + " Revision: " + Revision + '\n'
我试着用string.rjust & srting.ljust但无济于事工作。
对此提出建议?
string.ljust应该做你想做的。你可以发布你在.ljust舞台上试过的东西吗? – JoeFish
你总是可以使用'“\ t”' –
参见http://stackoverflow.com/questions/1448820/variable-length-of-s-with-the-operator-in-python#1448834 –