Python Code Samples



Filters


How to add markers and values to the line plot in python matplotlib
kishore_kumar | 7 years, 3 months
import matplotlib.pyplot as plt

t = ['12-03-18','12-04-18' , '12-05-18', '12-06-18', '12-07-18']
python matplotlib
delete files older than n days in a directory using python
kishore_kumar | 6 years, 2 months
import os
import time
base_path = '/home/kishore/my_files'
python os
Read nth line in a file using python
kishore_kumar | 6 years, 4 months
file_ob = open('/path/to/file')
n = 4
for i, line in enumerate(file_ob):
python
convert and decode base64 string into pdf using python
kishore_kumar | 6 years, 6 months
import base64

b64str = "a29kZXJwbGFjZQ=="
python base64
Ramya
Python: Vending Machine
Ramya | 6 years, 8 months
class SodaMachine:
    def __init__(self,product,price):
        self.product=product
python >>>from <file_name> import <class_name> >>>shop=class_name("product",price) #Instantiate
python
List all files and folders using python os module
kishore_kumar | 7 years, 8 months
import os

def list_files_folders(path):
python python-os
generate random numbers matrix with numpy python
kishore_kumar | 7 years, 6 months
import numpy as np

random_arr = np.random.randint(1,50,9)
python numpy
use python requests to get contents of url ( get request )
kishore_kumar | 7 years, 6 months
import requests

req = requests.get("https://httpbin.org/get")
python python-requests
Ramya
Lambda code for Creating VPC flow log automatically when a VPC is created
Ramya | 6 years, 11 months
from __future__ import print_function
import json
import os
lambda boto3 aws
Example to use a DAG to run a jar file.
Reshma | 6 years, 6 months
from airflow import DAG
from airflow.operators import BashOperator
from datetime import datetime
python airflow jar
Prev Next