Category: Python Tutorials

Python programming, installation, tutorials, errors, examples, how to guides for beginners

Python: Position of next occurrence of a sub-string

position-of-second-occurence-python

Python code to get the position of next or second occurrence of a sub-string within a string. # Below code finds the position of second occurrence of “xyz” string = “xyz is equal to xyz” firstSubPos=string.find(“xyz”) # get the position of first substring “xyz” secondSubPos=string.find(“xyz”, firstSubPos+1) # get the position of second occurence of substring […]

Python: Replace/remove string between two delimiters/characters

This Python code helps you to to replace a string between two delimiters or characters delete/remove string between two characters or delimiters Python code to replace string between two delimiters # This macro replaces nivas in below string with silveri string = “sri[nivas]” firstDelPos=string.find(“[“) # get the position of [ secondDelPos=string.find(“]”) # get the position […]

Extract string between two delimiters

Simple python script to extract sub string between two delimiters of a string. Examples of delimiters are brackets, parentheses, braces, single or double quotes etc. You can also customize this code to extract the string between two special characters or two sub strings. Comments on each line of code explains you to easily understand the code. Note: […]

Easy steps to install Python on Windows

Python-installation-check-on-windows

Below are the easy steps to install and setup python on Windows (I tried with Windows 10). click here to read Python2 or Python3? Download Python from https://www.python.org/downloads/ Install it on your C drive Search PowerShell from Start menu or Windows search box. Click on it to open. Type python in your PowerShell (Terminal) If you get […]

Simple steps to install openpyxl on Windows

Openpyxl is a python library to perform read/write excel xlsx/xlsm/xltx/xltm files. Below are the simple steps to install openpyxl on Windows Click below link to download openpyxl package Download openpyxl package Goto Navigation – > Download Files Download the openpyxl package by clicking on openpyxl.x.x.x.tar.gz file link (x.x.x is version number) Extract the downloaded TAR […]