ropering / Study

0 stars 0 forks source link

[Python] byte_size #12

Open ropering opened 2 years ago

ropering commented 2 years ago
'''
문자열의 길이를 바이트 단위로 반환
'''

def byte_size(string):
    return(len(string.encode('utf-8')))

byte_size('😀') # 4 
byte_size('Hello World') # 11