Python: getting correct string length when it contains surrogate pairs

前端 未结 3 566
太阳男子
太阳男子 2021-01-04 04:42

Consider the following exchange on IPython:

In [1]: s = u\'華袞與緼         


        
3条回答
  •  暖寄归人
    2021-01-04 05:26

    You can override the len function in Python (see: How does len work?) and add an if statement in it to check for the extra long unicode.

提交回复
热议问题