“Leer Fichero de Texto con Columans Como diccionario python” Ответ

Leer Fichero de Texto con Columans Como diccionario python

def get_pair(line):
    key, sep, value = line.strip().partition(" ")
    return int(key), value

with open("file.txt") as fd:    
    d = dict(get_pair(line) for line in fd)
Better Bee

Leer Fichero de Texto con Columans Como diccionario python

d = {}
with open("file.txt") as f:
    for line in f:
       (key, val) = line.split()
       d[int(key)] = val
Better Bee

Ответы похожие на “Leer Fichero de Texto con Columans Como diccionario python”

Вопросы похожие на “Leer Fichero de Texto con Columans Como diccionario python”

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

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