Daftar ke String Python
list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)
Amused Antelope
list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)
list1 = ['1', '2', '3']
str1 = ''.join(list1)
>>> L = [1,2,3]
>>> " ".join(str(x) for x in L)
'1 2 3'
lines2 = " ".join(lines) # Converts the list to a string.
# This should work for writing to a file
file.write(lines2)
mystring = 'hello, world'
myarray = string1.split(', ') #output => [hello, world]
myjoin1 = ', '.join(myarray) #output => hello, world
myjoin2 = ' '.join(myarray) #output => hello world
myjoin3 = ','.join(myarray) #output => hello,world