Category: New Python tutorial

python tutorials and learn python

Created with Sketch.

Python Raw Strings

Python Raw Strings Summary: in this tutorial, you will learn about the Python raw strings and how to use them to handle strings that treat the backslashes as literal characters. Introduction the Python raw strings In Python, when you prefix a string with the letter r or R such as r’…’ and R’…’, that string…
Read more

Python F-strings

Python F-strings Summary: in this tutorial, you’ll learn about Python F-strings and how to use them to format strings and make your code more readable. Introduction to the Python F-strings Python 3.6 introduced the f-strings that allow you to format text strings faster and more elegant. The f-strings provide a way to embed expressions inside…
Read more

Python pipenv

Python pipenv Summary: in this tutorial, you’ll learn how to configure a project with a new virtual environment using the Python pipenv tool. Creating a new project First, create a new project folder e.g., crawler. Second, navigate to the crawler folder and install the requests package using the pipenv command: pipenv install requests   Output:…
Read more

Install pipenv Windows

Install pipenv Windows Summary: in this tutorial, you’ll learn how to install the pipenv packaging tool on Windows. Prerequisites Before installing the pipenv tool, you need to have Python and pip installed on your computer. First, open the Command Prompt or Windows Powershell and type the following command. python -V   Note that the letter…
Read more

Python Virtual Environments

Python Virtual Environments Summary: in this tutorial, you’ll learn about Python virtual environments. Why do you need Python virtual environments? Python stores all system packages in a folder that you specify when installing Python. Typically, most system packages locate at subfolders of a path specified in the sys.prefix. To find this path, you can import…
Read more

Python pip

Python pip   Summary: in this tutorial, you’ll learn about Python pip and how to use it to manage third-party packages. Introduction to Python package index (PyPI) Python has a rich standard library that you can use immediately. In case you need a package that isn’t available in the standard library, you can find it…
Read more

Python Write Text File

Python Write Text File Summary: in this tutorial, you’ll learn various ways to write text files in Python. TL;DR The following illustrates how to write a string to a text file: with open(‘readme.txt’, ‘w’) as f: f.write(‘readme’) Code language: JavaScript (javascript) Steps for writing to text files To write to a text file in Python,…
Read more

Python Read Text File

Python Read Text File Summary: in this tutorial, you learn various ways to read text files in Python. TL;DR The following shows how to read all texts from the readme.txt file into a string: with open(‘readme.txt’) as f: lines = f.readlines() Code language: Python (python) Steps for reading a text file in Python To read…
Read more

Python Delete File

Python Delete File Summary: in this tutorial, you’ll learn how to delete a file from Python using the os.remove() function. To delete a file, you use the remove() function of the os built-in module. For example, the following uses the os.remove() function to delete the readme.txt file: import os os.remove(‘readme.txt’) Code language: Python (python) If…
Read more

Python Rename File 

Python Rename File Summary: in this tutorial, you’ll learn how to rename a file using the os.rename() function. To rename a file, you use the os.rename() function: os.rename(src,dst) Code language: CSS (css) If the src file does not exist, the os.rename() function raises a FileNotFound error. Similarly, if the dst already exists, the os.rename() function…
Read more