“Lista ciągów do listy INT Python” Kod odpowiedzi

Konwertuj listę ciągów na Ints Python

test_list = ['1', '4', '3', '6', '7'] 

int_list = [int(i) for i in test_list]
EDestroyer

Lista zmian na int w Python

test_list = list(map(int,test_list))
Ugliest Unicorn

Konwertuj listę na Python Integer

num = [1, 2, 3, 4]

s = [str(i) for i in num] # Converting integers into strings

result = str("".join(s)) # Join the string values into one string

print(result)
sej

Python przekonwertuje listę ciągów na listę liczb całkowitych

# Basic syntax:
list_of_ints = [int(i) for i in list_of_strings]

# Example usage with list comprehension:
list_of_strings = ['2', '3', '47']
list_of_ints = [int(i) for i in list_of_strings]
print(list_of_ints)
--> [2, 3, 47]
Charles-Alexandre Roy

ciąg Python do listy int

>>> example_string = '0, 0, 0, 11, 0, 0, 0, 0, 0, 19, 0, 9, 0, 0, 0, 0, 0, 0, 11'
>>> list(map(int, example_string.split(',')))  # Python 3, in Python 2 the list() call is redundant
[0, 0, 0, 11, 0, 0, 0, 0, 0, 19, 0, 9, 0, 0, 0, 0, 0, 0, 11]
>>> [int(s) for s in example_string.split(',')]
[0, 0, 0, 11, 0, 0, 0, 0, 0, 19, 0, 9, 0, 0, 0, 0, 0, 0, 11]
Unusual Unicorn

Lista ciągów do listy INT Python

results = [int(i) for i in results]
Clumsy Chimpanzee

Odpowiedzi podobne do “Lista ciągów do listy INT Python”

Pytania podobne do “Lista ciągów do listy INT Python”

Więcej pokrewnych odpowiedzi na “Lista ciągów do listy INT Python” w Python

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu