<>1. list list--------> character string str
First case , If list [ ] The elements contained in are str " " type .
Use the following method , give an example .
nums=['ww','22','2s'] print("".join(nums))
Operation results :
ww222s
The second situation , If the list [ ] The elements in it are shaping int , It needs to be reshaped int convert to str type .
nums=[1,2,3,4,5] strNums=[str(x) for x in nums] print("".join(strNums))
Input results :
12345
<>2. character string str----------> list list
strnums1='12123112' strnums2='sdfsdsdf' listnums1=list(strnums1) listnums2=list
(strnums2) print(listnums1) print(listnums2)
Output results :
[‘1’, ‘2’, ‘1’, ‘2’, ‘3’, ‘1’, ‘1’, ‘2’]
[‘s’, ‘d’, ‘f’, ‘s’, ‘d’,‘s’, ‘d’, ‘f’]
Technology