“Список Python to String” Ответ

Список на строку Python

list1 = [1, 2, 3]
str1 = ''.join(str(e) for e in list1)
Amused Antelope

Список строк Python для перечисления

>>> import ast
>>> x = '[ "A","B","C" , " D"]'
>>> x = ast.literal_eval(x)
>>> x
['A', 'B', 'C', ' D']
>>> x = [n.strip() for n in x]
>>> x
['A', 'B', 'C', 'D']
Fragile Gecko

конвертировать список в String Python

# Python program to convert a list 
# to string using list comprehension 
   
s = ['I', 'want', 4, 'apples', 'and', 18, 'bananas'] 
  
# using list comprehension 
listToStr = ' '.join([str(elem) for elem in s]) 
  
print(listToStr)  
Frantic Falcon

Список Python to String

By using ''.join

list1 = ['1', '2', '3']
str1 = ''.join(list1)
Stupid Shrew

Список Python to String

mystring = 'hello, world'

mylist = string1.split(', ') #output => ['hello', 'world']

myjoin1 = ', '.join(mylist) #output => 'hello, world'
myjoin2 = ' '.join(mylist) #output => 'hello world'
myjoin3 = ','.join(mylist) #output => 'hello,world'
NatanM

Список Python to String

list
Curious Caiman

Ответы похожие на “Список Python to String”

Вопросы похожие на “Список Python to String”

Больше похожих ответов на “Список Python to String” по Python

Смотреть популярные ответы по языку

Смотреть другие языки программирования