Python
Snippets
.Dev
Archive
Login with GitHub
Byte size of string
This method returns the length of a string in bytes.
Python: 3.0
Fatos Morina
03 Jul 2021
0
Login to upvote
1
2
3
4
5
def
byte_size
(string):
return
(len(string.encode(
'utf-8'
)))
byte_size(
'Hello World'
)
# 11
def byte_size(string): return(len(string.encode('utf-8'))) byte_size('Hello World') # 11
Copy
| Download as:
.py file
PNG
Share on:
FB
Twitter
LinkedIn
WA
Previous
Random Snippet
Next
©2021 - code108labs Contributors Hosted on
DigitalOcean
Partner website:
pythoncircle.com