Python Code Samples



Filters


Python pickle dump
Reshma | 5 years, 9 months
import pickle

number_of_data = int(input('Enter the number of data : '))
python pickle dump
Save full traceback from exception in python
kishore_kumar | 5 years, 12 months
import traceback

l = [1,2,3]
python exception
how to log full traceback using python logging
kishore_kumar | 5 years, 12 months
import logging
  
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=
python logging
durga
Writing into files in python
durga | 6 years, 1 month
file = open('open.txt','w') 
 
file.write('Hi there!') 
python file handling
python base64 encode and decode a string
kishore_kumar | 6 years, 2 months
import base64

str1 = "koderplace"
python base64
Simple singly Linked List in python
kishore_kumar | 6 years, 6 months
class Node(object):
    def __init__(self, data=None, next_node=None):
        self.data = data
python linked list
get all keys from redis with python
kishore_kumar | 5 years, 9 months
import redis # pip install redis
r = redis.Redis(host='localhost', port='6379')

python redis
How to access django models in stand alone python script without manage.py
kishore_kumar | 5 years, 11 months
import os
import django

python django
How to load a pickle file in python
harika | 5 years, 11 months
with open('train.pickle', 'rb') as f:
    X_train, y_train = pickle.load(f)
python pickle file
convert python date time object to specific format using strftime
kishore_kumar | 6 years
import datetime

st = "2019-08-19 05:40"
python datetime
Prev Next