The Self-Taught Developer: Tips and Tricks for Anyone to Learn Programming by Tommy Chheng

The Self-Taught Developer: Tips and Tricks for Anyone to Learn Programming by Tommy Chheng

Author:Tommy Chheng [Chheng, Tommy]
Language: eng
Format: epub
Published: 2020-12-15T23:00:00+00:00


Examples of Writing and Reading Data

CSV

import csv with open('books.csv', 'wt') as outfile: writer = csv.writer(outfile, delimiter=',') writer.writerow(['1', 'a tale of two cities']) writer.writerow(['2', 'the three body problem']) with open('books.csv') as infile: reader = csv.reader(infile, delimiter=",") for row in reader: print(row)

JSON

import json data = {'books': [{'id': 1, 'title': 'a tale of two cities'}, {'id': 2, 'title': 'the three body problem'}]} with open('books.json', 'w') as outfile: json.dump(data, outfile) with open('books.json') as infile: data = json.load(infile) for book in data['books']: print(book)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.