Truncate beginning of string with str.format
问题 I'd like to allign a string to the right but have its beginning be truncated instead of its end. I tried this: my_str = '01234567890' print "{0:>4.4}".format(my_str) Output: '0123' Desidered Output: '7890' Is there a way to do this with format or do I have to cut the string before feeding it? 来源: https://stackoverflow.com/questions/30721292/truncate-beginning-of-string-with-str-format