Category: Python

Strip trailing whitespaces from string [Python]

strip-trailing-white-spaces-Python-code

If you want to remove extra whitespaces from start and end of a string, use strip() method in Python. strip() method removes all default whitespaces (spaces and tabs \t) and returns the copy of the string. Python code to strip trailing whitespaces from string

Note: Code works in both Python 2 and 3 Output […]

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.

Note: Above code works in both Python 2 and Python 3 Output:

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

Python code to delete/remove string between two characters/delimiters Replace 5th line of above code with below one

Note: This code works in both […]

Easy steps to install Python on Windows

Python-installation-check-on-windows

Below are the easy steps to install python on Windows (I tried with Windows 10). Install Python (Download it from http://python.org/download) 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 any error or python is not recognized, then […]

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 Extract the downloaded TAR file (recommended to extract it to python folder on C drive) Open command prompt or Powershell Navigate to the folder that you […]