Python Code Samples



Filters


durga
Writing into files in python
durga | 5 years, 8 months
file = open('open.txt','w') 
 
file.write('Hi there!') 
python file handling
Python pickle dump
Reshma | 5 years, 4 months
import pickle

number_of_data = int(input('Enter the number of data : '))
python pickle dump
Remove directory / folder in python
harika | 6 years, 2 months
'''
You can remove empty directory by rmdir function.
But to remove non empty directory we have to
Shuttle : A module that offers a number of high-level operations on files and collections of files.
shutil python os
how to log full traceback using python logging
kishore_kumar | 5 years, 7 months
import logging
  
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', datefmt=
python logging
How to access django models in stand alone python script without manage.py
kishore_kumar | 5 years, 6 months
import os
import django

python django
convert python date time object to specific format using strftime
kishore_kumar | 5 years, 8 months
import datetime

st = "2019-08-19 05:40"
python datetime
send mail using sendgrid python
kishore_kumar | 5 years, 8 months
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
python sendgrid
how to extract text content from pdf file using python
kishore_kumar | 6 years, 2 months
from tika import parser # pip install tika

process = parser.from_file('/path/to/my.pdf')
python tika
Image labels detection using google Vision API in python
kishore_kumar | 6 years, 1 month
from google.cloud import vision
from google.cloud.vision import types

If you setup env variable with export GOOGLE_APPLICATION_CREDENTIALS="/file/creds.json" then you ca
python google vision
How to dump data to a pickle file in python
harika | 5 years, 6 months
X_train = []
y_train = []
with open('train.pickle', 'wb') as f:
python pickle file
Prev Next