1. 字符串超过某个长度,截取,后面加…

适用于超长字符串和短字符串,此次长度为4

long_str = "超长字符截取sdjaljdslajsljasldjla"
short_str = long_str[:4] + (long_str[4:] and '...')
short_str
# output: '超长字符...'

string = "短字符"
short_str = string[:4] + (str[4:] and '...')
short_str
# output: '短字符'