77236893;
LI_week_hit = 88831079;
LI_week_vis = 20813386;
LI_day_hit = 11914362;
LI_day_vis = 3943745;"""
где ты ее взял
a = {} for c in your_str.split(";"): key, value = c.split(" = ") a[key] = value
Input In [2], in <cell line: 9>() 8 a = {} 9 for c in your_str.split(";"): ---> 10 key, value = c.split(" = ") 11 a[key] = value 13 print(a, type(a)) ValueError: not enough values to unpack (expected 2, got 1) =))
your_str = """LI_month_hit = 385999401; LI_month_vis = 77236893; LI_week_hit = 88831079; LI_week_vis = 20813386; LI_day_hit = 11914362; LI_day_vis = 3943745;""" a = {} for c in your_str.split(";\n"): key, value = c.split(" = ") a[key] = value print(a, type(a))
text = """LI_month_hit = 385999401; LI_month_vis = 77236893; LI_week_hit = 88831079; LI_week_vis = 20813386; LI_day_hit = 11914362; LI_day_vis = 3943745;""" dictionary = {} for line in text.replace(";", "").split("\n"): key, value = line.split(" = ") dictionary[key] = value print(f"{text}\n\nwas remade to dictionary:\n\n{dictionary}
Сплит тогда уж без переноса строки можно
Никак в том-то и дело. Сплит по дефолту делит по пробелам, не по \n символу
Не на то ответил)) Хотел на это
Обсуждают сегодня