Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make a dict from a file py

dictionary = {}
file = open("data.txt")
for line in file:
key, value = line. split() # Split line into a tuple.
dictionary[key] = value # Add tuple values to dictionary.
print(dictionary)
Comment

PREVIOUS NEXT
Code Example
Python :: django message 
Python :: beautifulsoup check if text exists 
Python :: remove part of string python 
Python :: pyautogui locatecenteronscreen mac fix 
Python :: to str python 
Python :: how to access variables from a class in python 
Python :: max of double array python 
Python :: arg parse array argument 
Python :: how to make every letter capital in python 
Python :: squre value of a column pandas 
Python :: overriding update in serializer django 
Python :: z score formula in pandas 
Python :: python variable is not none 
Python :: send mail through python 
Python :: captions overlap in seaborn plot jupyter 
Python :: find number of unique keys in the dictionary 
Python :: Insurance codechef solution 
Python :: how to make python code faster 
Python :: not in python 
Python :: pyjwt 
Python :: get the list of column names whose data type is float python 
Python :: iterate through a list 
Python :: User serializer in django rest framework 
Python :: install os conda 
Python :: plot multiindex columns pandas 
Python :: count how much a number is in an array python 
Python :: select rows in python 
Python :: how to download from url in python 
Python :: range function 
Python :: calculate perimeter of rectangle in a class in python 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =