Skip to content

Instantly share code, notes, and snippets.

@luisenriquecorona
Created April 18, 2019 17:28
Show Gist options
  • Save luisenriquecorona/1ebeb855297fdc80c4ebfc895ae53ffe to your computer and use it in GitHub Desktop.
Save luisenriquecorona/1ebeb855297fdc80c4ebfc895ae53ffe to your computer and use it in GitHub Desktop.
Translate to normal string
>>> S = 'shrubbery'
>>> L = list(S)
>>> L
['s', 'h', 'r', 'u', 'b', 'b', 'e', 'r', 'y'] >>> L[1] = 'c'
>>> ''.join(L) 'scrubbery'
>>> B = bytearray(b'spam') >>> B.extend(b'eggs')
>>> B bytearray(b'spameggs')
>>> B.decode() 'spameggs'
# Expand to a list: [...]
# Change it in place
# Join with empty delimiter
# A bytes/list hybrid (ahead) # 'b' needed in 3.X, not 2.X # B[i] = ord(c) works here too
# Translate to normal string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment