Display width of unicode strings in Python [duplicate]
问题 This question already has answers here : Normalizing Unicode (2 answers) Closed 5 years ago . How can I determine the display width of a Unicode string in Python 3.x, and is there a way to use that information to align those strings with str.format() ? Motivating example: Printing a table of strings to the console. Some of the strings contain non-ASCII characters. >>> for title in d.keys(): >>> print("{:<20} | {}".format(title, d[title])) zootehni- | zooteh. zootekni- | zootek. zoothèque |