Convert python string and list to each other

Because python's read and write methods operate on strings. When operating binary, the string will be converted into a list for parsing, and when the file is rewritten after parsing, it must be converted into a string.

>>> import string
>>> str = 'abcde'
>>> list =  list(str)
>>> list
['a', 'b', 'c', 'd', 'e']
>>> str
'abcde'
>>> str_convert =  ''.join(list)
>>> str_convert
'abcde'
>>>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324796911&siteId=291194637