Python Basics: Making Network Requests with the Requests Library

Python Basics: Making Network Requests with the Requests Library

When learning Python, we often need to interact with the web, such as scraping web pages, calling third-party APIs, or retrieving data from backend services. Although Python’s built-in <span>urllib</span> is comprehensive, it can feel a bit cumbersome to use. At this point, let me introduce a “great helper”—requests. It allows you to perform various HTTP … Read more

Understanding Python Scope and Recursive Functions

Understanding Python Scope and Recursive Functions

Python Scope Local Scope: Variables defined within a function have local scope and can only be accessed inside that function. When the function execution ends, these local variables are destroyed. For example: def my_function(): local_variable = 10 print(local_variable) my_function() # print(local_variable) # This line will raise an error because local_variable is out of scope Global … Read more

The Ultimate Guide to Playwright: The Python Automation Tool That Makes Browsers Obey!

The Ultimate Guide to Playwright: The Python Automation Tool That Makes Browsers Obey!

Imagine being a programmer who has to repeat some boring and tedious tasks every day— logging into websites, submitting forms, scraping data, checking webpage content, or taking screenshots and recording screens. Isn’t it annoying? Now, what if we told you that Python can make browsers obey through automation tools and help you complete these heavy … Read more

28 Common Python API Automation Testing Scripts

28 Common Python API Automation Testing Scripts

Practical Guide to Python API Automation Testing Scripts 1. Basic HTTP Request Testing 1.1 Basic GET Request Testing Using the Requests Library import requests import unittest class TestGetApi(unittest.TestCase): def test_get_request(self): # Send GET request response = requests.get('https://jsonplaceholder.typicode.com/posts/1') # Assert status code is 200 self.assertEqual(response.status_code, 200) # Assert response contains expected keys data = response.json() self.assertIn('id', … Read more

Basic Inquiry Data Return Processing in Python Mini Programs

Basic Inquiry Data Return Processing in Python Mini Programs

Introduction Control Yourself. Achieving success is not difficult for a person. In my youth, I read a book called “Karl Maintains Education,” which tells the story of a father raising a child with cerebral palsy to become a PhD. I believe the essence of the book is about controlling oneself and developing good habits. It … Read more

Incremental Assignment of Sequences in Python

Incremental Assignment of Sequences in Python

Incremental Assignment of Sequences The behavior of the incremental assignment operators += and *= depends on their first operand. For simplicity, we will focus on incremental addition (+=), but these concepts apply equally to *= and other incremental operators. The special method behind += is iadd (used for “in-place addition”). However, if a class does … Read more

Solutions for Python SSL Certificate Verification Failure

Solutions for Python SSL Certificate Verification Failure

When using Python for data collection, we often encounter error messages like the one below: URLError: <urlopen error[SSL:CERTIFICATE_VERIFY_FAILED]> Cause Analysis: The first reason is that if a self-signed certificate is used, the internal server or development environment may employ a self-signed SSL certificate. Since these certificates are not signed by a public Certificate Authority (CA), … Read more

Introduction to Python Series Part 12 (Database Operations)

Introduction to Python Series Part 12 (Database Operations)

1. Introduction In application development, data management, such as data storage and retrieval, is a fundamental requirement. Regardless of the type or scale of the application, data storage management is essential. In most business applications, the two most commonly used types of databases are NoSQL databases, such as Redis, and relational databases, such as MySQL. … Read more

Basic Python Tutorial

Basic Python Tutorial

Python is a simple, powerful programming language that is suitable for both beginners and professional developers. This tutorial will introduce the basic concepts of Python. 1. Introduction to Python Python is a high-level, interpreted, general-purpose programming language, first released by Guido van Rossum in 1991. It has the following features: Simple and readable syntax Cross-platform … Read more

Getting Started with Python: Don’t Let These Pitfalls Delay Your Programming Journey

Getting Started with Python: Don't Let These Pitfalls Delay Your Programming Journey

Friends, have you watched a bunch of Python tutorials but still can’t write code? Don’t worry, today I will share some practical tips that those tutorials didn’t cover. 1. Understand this first: How does Python actually run code? Many beginners don’t even know how to execute a .py file. Try this: Execution method: Open the … Read more