This article is participating in Python Theme Month. See the link for details

preface

Hello everyone! I’m front-end nameless

background

Python is coming in July, just in time to push myself to learn a wave of Python, and output drives learning. As early as a few years ago, I have been unknowingly exposed to Python. My exposure to Python began with testerSunshine / 12306(snatching train tickets) and masks during the epidemic. I used to operate according to readme. md with the big guy’s project, encountered problems, did not know how to modify the code, this time I can learn seriously.

Nonsense fill how much, open, build development environment!

Learn Python Chinese language.

Setting up the development environment

Software installation

Go to the official website to download the Python package, install it directly, be sure to check the add environment variables! Otherwise, you need to configure it manually, please.

Once installed, verify that it was installed correctly.

You can see that the Python version is displayed, and we have installed it successfully!

Editor selection

1. If you need to write Python programs, you must have a developer tool to help you check the code, prompt, auto-complete, etc. Looking at the Python basics tutorial, I saw that I needed to follow the editor Pycharm. As a front-end engineer, I didn’t want to install it. VSCode is so powerful, I first see VSCode support does not support, sure enough, VSCode did not disappoint me!

Install the Python plugin directly!

The lower right corner of VScode prompts you to install the formatting plug-in directly.

Write the Demo

1. Create a new file demo1.py and write Hello World!

    print("hello world")

    Multi-line comment
    # single-line comment

    def aaa() :
        print("1111")

    aaa()
Copy the code
  1. Run Python code.

Python package management tool PIP

Python programs such as testerSunshine/12306 often make us execute PIP. What is PIP? Ask Baidu.

What is the PIP

PIP is the Package manager for Python. This means that it is a tool that allows you to install and manage other libraries and dependencies that are not part of the standard library. PIP has been included directly in Python installation packages since Python3 version 3.4 and Python2 version 2.7.9.

Similar to our NPM tool.

How to Update PIP

Command line input

 pip install --upgrade pip
Copy the code

or

 python -m pip install --upgrade pip
Copy the code

How do I change the mirror source

NPM can set taobao mirror source, PIP default installation source is abroad, is there a good mirror source to choose?

Domestic mirror:

Pypi.douban.com/simple/ douban

Mirrors.aliyun.com/pypi/simple… Ali.

Pypi.hustunique.com/simple/ huazhong university of science and technology

Pypi.sdutlinux.org/simple/ shandong polytechnic university

Pypi.mirrors.ustc.edu.cn/simple/ university of science and technology of China

Pypi.tuna.tsinghua.edu.cn/simple tsinghua

Set command:

 pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
Copy the code

PIP installation package backup

When we are multi-developer, we want to keep the three-party package version consistent to run the application perfectly. We use package.json to configure the installed third-party package version information.

Is PIP configured for file sharing?

One-click export:

 pip freeze > requirement.txt
Copy the code

A key to install

 pip install -r requirement.txt
Copy the code

This is ready to install.

Github installs some examples of ticket grabbing projects:

 pip install -i https://xxxxx.cn -r requirement.txt
Copy the code

After the language

Good environment, start my Python journey, welcome your comments. Give it a thumbs up! Comments are welcome.