Python Learning Diary

1. July 8, 2025

I think learning programming is very important! So I want to learn programming! I believe programming can do many things! Although I don’t know what can be done! But once I learn, I will know! What should I learn first? Let’s start with web scraping! Python is said to be the easiest!

I downloaded version 3.12.0 and found tutorial videos on Bilibili. Web scraping has legal risks, so do not damage website resources or steal user privacy.

The robots.txt protocol indicates what can be scraped and what cannot.

Following the tutorial, I downloaded the community version of PyCharm.

When downloading Python, make sure to select the option to add it to the environment variables. If you don’t check this, you will have to set it in the control panel.

Web scraping is like simulating a browser with a program, entering a URL to retrieve resources from that URL.

Oh no, I still don’t understand this introductory tutorial. I have never written code before, and I don’t know whether to use Chinese or English parentheses, nor do I know if I should add spaces before and after the equals sign. This introductory tutorial is not beginner-friendly enough; I need to search for another one.

2. July 15, 2025 What a coincidence, I haven’t touched it for a week, and today I came back. In the comments of the last downloaded video, someone said this tutorial focuses too much on teaching web scraping rather than Python itself, and recommended Lin Lili’s tutorial, so I went to find Lin Lili’s. While waiting for the cache, I watched the first lesson of the previous tutorial and asked DeepSeek some seemingly silly questions, like what parentheses mean and what the dot means. DeepSeek initially used a lot of technical terms that I didn’t understand, so I told him I was a beginner, and then he started explaining with practical examples like apples and baskets. Lin Lili’s tutorial is indeed great! Especially beginner-friendly. Adding quotes makes it treated as text; without quotes, it’s a variable. Wow! She even told me that if there’s an error, there will be a prompt, and just copy and paste the prompt into AI to find out where the error is. This is so practical! In Python, quotes are not distinguished as left or right! I feel like I’m getting it! Finding the right tutorial is half the battle! I love Teacher Lin Lili! It gives me a feeling of being incredibly powerful right now!

3. July 16, 2025

Variables cannot have spaces and cannot start with a number. Variable names can only use letters, numbers, and underscores. Try to avoid using Chinese for variable names, although Python 3.0 and later can support Chinese. Do not use keywords as variable names; once used, that word cannot be used as a keyword in that file anymore.

Using Python for addition, subtraction, multiplication, and division; exponentiation is done with two asterisks, 2**3 is two raised to the power of three. For more complex calculations, you need to import the math module (actually, print is also a function, but because it’s so commonly used, it’s considered a built-in function). Import math, and then you can use math.function_name(), for example, math.sin(1). However, this is just for calculations; you also need to use print to output the results.

4. July 20, 2025 # The following is used for comments and will not be executed. If a comment has multiple lines, each line must start with a hash. If you have a piece of code you don’t want to execute but don’t want to delete, you can add a hash. You can also use triple quotes to enclose multiple lines of comments. Data types: strings, integers, floating-point numbers, boolean types, None type, lists, dictionaries. The type function outputs the data type. For strings, you can use square brackets to access characters at specific indices. The programming world starts counting from 0, so the first data is 0. -1 will give you the last value. Command line mode and interactive mode. In interactive mode, you get immediate output after entering a line, and you don’t need to write print. That’s all for today; there are still 24 lessons left, and I can learn them in 8 days.

5. July 21, 2025 input always returns a string, even if the input is a number, it will be treated as a string. The int function can convert a string to an integer. The float and str functions work similarly. One equals sign is for assignment, while two equals signs are for comparison. The not equal sign is !=. A colon must be added after the condition to indicate the end of the condition, and the following statements must be indented, preferably with four spaces. else cannot exist independently of if. Python allows chaining two less-than signs.

6. July 23, 2025 Logical operators: and, or, not. Priority: not > and > or. An empty list is represented by a pair of square brackets, with items separated by commas. .append can add items to a list. Method: object.method_name(…). Function: function_name(object). Lists are mutable, while other data types are immutable. After using a method, the assignment of strings and integers does not change, but the list does change. Python lists can contain different types of data. Dictionaries are used to store key-value pairs. contacts = {}. The key type must be immutable. Tuples can hold multiple elements and are represented by parentheses. Tuples are immutable.

7. July 26, 2025 for variable_name in iterable_object. range(5, 10) is an integer sequence, and the end value is not included in the range. range(5, 10, 2) specifies the start value, end value, and step. while condition A: Action B. Many times, for loops and while loops can be interchangeable. format method. f-string.

8. August 3, 2025 Defining functions. The code inside a function only runs when called. The definition inside a function will not be defined outside of it. Running a piece of code through a function is different from running it directly. The return statement can return the value of a variable at the end, allowing that value to be used outside the function. The website pypi.org can be used to search for third-party modules.

9. August 4, 2025 Object-oriented programming (OOP). In contrast to procedural programming. Procedural programming is chronological, while object-oriented programming is biographical. Encapsulation, inheritance, polymorphism. This is somewhat difficult to understand; Teacher Lin Lili explains it very clearly, but practical application is too difficult. From here on, I might not be able to handle it.

10. August 10, 2025 File location can be specified using two methods: absolute path (based on the root directory) and relative path (based on the reference directory). You can directly open a file path using the open function. r is read-only, w is write-only. The program will remember the position of the file read; after the first read is complete, the second read will return empty. You can specify how many bytes to read from the file. You can also use readline to read one line at a time. txt is easier to read than word. w is for write mode; if a file already exists, it will be cleared. If you want to append, use a. r+ supports both read and write simultaneously. Exception types: index error, division by zero error, file not found error, type error. There are many others. try/except will catch all types of errors. unittest is Python’s built-in unit testing library, but you still need to use import to include it.

11. August 11, 2025 Anonymous functions, I don’t understand this. In short, they are used once. I finished watching Lin Lili’s Python video course. It was quite good. I take these courses to understand some fundamental concepts so that I can give instructions to AI later, rather than writing code from scratch. My future plans may include: 1) Continuing to watch other videos by Lin Lili. 2) Watching other more complex Python videos to learn how to do web scraping. 3) Using Python to download some things. 4) Reading some introductory books on Python, such as “Python Programming: From Beginner to Practice.” 5) Learning other programming tools (long-term plan). This post ends here! I will record any new progress in the future!

Leave a Comment