Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

save list python

>>> import pickle
>>> l = [1,2,3,4]
>>> with open("test", "wb") as fp:   #Pickling
...   pickle.dump(l, fp)
... 
>>> with open("test", "rb") as fp:   # Unpickling
...   b = pickle.load(fp)
... 
>>> b
[1, 2, 3, 4]
Comment

save list python

>>> import json
>>> with open("test", "w") as fp:
...     json.dump(l, fp)
...
>>> with open("test", "r") as fp:
...     b = json.load(fp)
...
>>> b
[1, 2, 3, 4]
Comment

PREVIOUS NEXT
Code Example
Python :: df from numpy array 
Python :: cv2 save video mp4 
Python :: pygame fullscreen 
Python :: django python base 64 encode 
Python :: update my anaconda 
Python :: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly 
Python :: how to convert a list into a dataframe in python 
Python :: when did guido van rossum create python 
Python :: tkinter boilerplate 
Python :: how to clear console in repl.it python 
Python :: pandas plot xlabel 
Python :: tensorflow turn off gpu 
Python :: PRINT VS RETURN IN PYTHON 
Python :: seaborn create a correlation matrix 
Python :: dataframe to list 
Python :: droaw heat map in python for null values 
Python :: python read xls 
Python :: marks input using list in python 
Python :: plt plot circle 
Python :: python dockerfile 
Python :: how to get variable from setings django 
Python :: how to print right angle triangle in python 
Python :: remove x label matplotlib 
Python :: hello worldpython 
Python :: get text between two strings python 
Python :: how to get the angle of mouse from the center 
Python :: pandas index to list 
Python :: jupyter plot not showing 
Python :: float number field django models 
Python :: print time python 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =