在Python 2.5中,使用rjust(在字符串上)。另外,尝试习惯于使用python中的字符串格式,而不仅仅是串联字符串。下面是rjust和字符串格式的简单示例:
width = 10str_number = str(ord('a'))print 'a%s' % (str_number.rjust(width))
在Python 2.5中,使用rjust(在字符串上)。另外,尝试习惯于使用python中的字符串格式,而不仅仅是串联字符串。下面是rjust和字符串格式的简单示例:
width = 10str_number = str(ord('a'))print 'a%s' % (str_number.rjust(width))