Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to save python list to file

import json
a = [1,2,3]
with open('test.txt', 'w') as f:
    f.write(json.dumps(a))

#Now read the file back into a Python list object
with open('test.txt', 'r') as f:
    a = json.loads(f.read())
Comment

PREVIOUS NEXT
Code Example
Python :: autoslugfield django 3 
Python :: pip code for pytube 
Python :: numpy for data science 
Python :: get file name from url python 
Python :: pandas dataframe set datetime index 
Python :: python youtube downloader mp3 
Python :: display cv2 image in jupyter notebook 
Python :: create pandas dataframe with random numbers 
Python :: install python 3.9 ubuntu 
Python :: python change working directory to file directory 
Python :: save list pickle 
Python :: python show interpreter path 
Python :: remove first row of dataframe 
Python :: how to save a png seaborn pandas 
Python :: setwd python 
Python :: tk table python 
Python :: join list with comma python 
Python :: how to install python3 on ubuntu 
Python :: python barcode generator 
Python :: syntax to update sklearn 
Python :: frequency count of values in pandas dataframe 
Python :: pyyaml install 
Python :: urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123) 
Python :: créer des variable dynamiques python 
Python :: sort two lists by one python 
Python :: sklearn minmaxscaler pandas 
Python :: save crontab python to file 
Python :: python seaborn lmplot add title 
Python :: django admin prefetch_related 
Python :: python pendas shut off FutureWarning 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =