Truncate beginning of string with str.format

痴心易碎 提交于 2019-12-11 04:34:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!