diff --git a/README.md b/README.md index 7227862..e198ea1 100644 --- a/README.md +++ b/README.md @@ -1211,6 +1211,7 @@ Plot ```python # $ pip3 install matplotlib from matplotlib import pyplot + pyplot.plot( [, , ...]) pyplot.show() pyplot.savefig(, transparent=True) @@ -1223,6 +1224,7 @@ Progress Bar # $ pip3 install tqdm from tqdm import tqdm from time import sleep + for i in tqdm(range(100)): sleep(0.02) for i in tqdm([1, 2, 3]): @@ -1237,6 +1239,7 @@ Table # $ pip3 install tabulate import csv from tabulate import tabulate + with open(, newline='') as csv_file: reader = csv.reader(csv_file, delimiter=';') headers = [a.title() for a in next(reader)] @@ -1273,6 +1276,7 @@ Image ```python # $ pip3 install pillow from PIL import Image + width, height = 100, 100 img = Image.new('L', (width, height), 'white') img.putdata([255*a/(width*height) for a in range(width*height)]) @@ -1292,6 +1296,7 @@ Audio #### Saves a list of floats with values between 0 and 1 to a WAV file: ```python import wave, struct + frames = [struct.pack('h', int((a-0.5)*60000)) for a in ] wf = wave.open(, 'wb') wf.setnchannels(1) @@ -1429,6 +1434,7 @@ timeit('"-".join(str(a) for a in range(100))', # $ pip3 install pycallgraph from pycallgraph import output, PyCallGraph from datetime import datetime + graph = output.GraphvizOutput() time_str = datetime.now().strftime('%Y%m%d%H%M%S') graph.output_file = f'profile-{time_str}.png'