1. Introduction

I haven’t written in a long time. I’ve been working on some fun techniques using Python. I thought it would take some time, but after the first day of learning it, I didn’t deliberately learn it. Here are some of the key points. If I learn a language not because it’s popular but because I use it. I used to learn Kotlin, Vue and React when I was idle, but I never used them in practice, so that I almost forgot them now. So this is a painful lesson: don’t learn anything you might not need. Doesn’t it smell good when you have time to play games with girls?

2. Why Python

“Snake” is actually a no-no. I’m going to build a crawler and data cleaning, including some machine learning stuff. These are areas where Python has an inherent advantage, making Python the obvious choice. From here you need to know when you’re going to learn a new technology, you need to know what the advantages are, what the scenarios are. A lot of people sign up for a Python class, and when you ask them why they’re learning Python, they tell you because it’s popular. There is no future in this.

3. How to get started with Python quickly

This article is based on my personal experience, so if you want to get started quickly, first of all, you need to have programming experience, with the premise of mastering any other language, have a certain learning ability, Python is almost no difficulty for you.

3.1 Environment Installation and Package Management

Most people learn Python and use it directly to the official environment package installed on the line, of course, this can also be. In fact, if you use it a lot, there’s an environmental problem. It is recommended to use Anacoda3 directly. This can be seen as Maven or Gradle in Python. In the future, you may have problems with projects that rely on Python2 or Python3. Anacoda3 can help you solve specific environment management problems.

3.2 A language that generalizes code blocks by indentation

This is one of the things that makes Python special. It does not use curly braces {} to control the hierarchy of classes, functions, and other logical judgments. In Java you would write:

 public void test(String str){
       if(str! =null){
          System.out.println("str ="+ str);
       }else{
         System.out.println("str is null"); }}Copy the code

In Python we write:

  def test(str):
      if str:
         print('str')
      else:
         print('None') 
Copy the code

You can see from this that Python is sparing everything possible, including variable types and return value types. This is a little “loose” as an object-oriented language, but very useful as a scripting language. As I write this article, I need to change the size of my id photo, which Python does:

 file_dir = './2.jpg'
 
 with Image.open(file_dir) as img:
     x, y = img.size
     x_s = 650
     y_s = y * x_s / x
     out = img.resize((int(x_s), int(y_s)), Image.ANTIALIAS)
     out.save('./3.jpg')
Copy the code

Learning Python is easy if you know another language. So the basic syntax is almost a go through. Advanced features suggest learning as you go; don’t waste time on them. Learning any language is a lot of practice and writing. Just as sharpshooters are fed bullets, a good Coder needs a certain amount of code.

3.3 the difficulty

I think the only one that takes more time is the slice. Slicing is taking values from a list or tuple by range. Very flexible, slices have both positive and reverse order. This is one of the reasons Python is so good at handling data. It takes a lot of time to pick up exercises and understand operational data. Machine learning, science experiments, data analysis.

4. How to learn quickly

It is recommended to start with a small set of requirements and solve problems when you encounter them. Then focus on practicing and understanding technical solutions to your problems. I didn’t follow the rules after I wrote HelloWorld. Got a crawler script to try to crawl things. And to understand some of the writing, and then put some of their own ideas into the implementation. Practice data processing can be connected to a database, a variety of data aggregation operations. When you learn something new, you often don’t know what will improve you most immediately. Only need can help you find your weaknesses and see your direction clearly. Don’t obsess over some language feature you don’t know how to use.

5. Switch as much as you like

“Playing snake” is playing switch! A good Python Coder is a shifter! Python has a very rich class library that allows you to implement all kinds of ideas. So don’t try to build a wheel when you encounter a scene in Python. Find a wheel first. Here are a few common wheels you can use while studying:

  • BeautifulSoup is a must for crawlers
  • Pillow Image processing library. For example, I gave the beauty above to help P map is it, win goodwill necessary.
  • Numpy basic package for high performance scientific computing and data analysis. Machine learning is a must.
  • Pandas Data analysis will be learned

There are many more, but the ones above are very powerful in some areas and can be eaten if played well.

6. Summary

Python is great as a second language and very quick to learn. Usually processing point data is very handy, play very cool. If you want to do some artificial intelligence things, the threshold is higher, mathematics, statistics, probability, English, modeling a can not be less. So if you want to eat Python, you have to look at your abilities. Just knowing Python doesn’t give you an advantage, and it’s not worth taking a class because it’s easy to learn.