Home >Backend Development >Python Tutorial >python contains Chinese string length
Python contains the length of Chinese strings
A Chinese utf8 encoding occupies 3 characters, so the function to find the length can be written like this
def str_len(str): try: row_l=len(str) utf8_l=len(str.encode('utf-8')) return (utf8_l-row_l)/2+row_l except: return None return None