What is? Python?

  • Dynamic interpretive language ,1982 Year by the Dutch Guido von Rossum The invention .
  • More details can be google, There is no expansion here .

Python Interpreter :

  1. CPython( Official version C Language implementation )
  2. IronPython( Can run in .NET and Mono platform )
  3. PyPy(Python Realization , Support JIT Just in time compilation )
  4. Jython( Running on the Java platform )
  • This article is only for learning Cpython be based on Python3.8+

Python Advantages and disadvantages :

  • Simple , studies of the Book of Changes , Open source , object-oriented , Scalable , Rich wheels .
  • Slow execution , Common faults of dynamic scripting languages , So computing intensive should rely on C Language and other compiler language implementation .

Python Philosophy of design

  • grace
  • clear :
  1. In a way , It's better to have only one way to do one thing
  2. If there are multiple options ,Python Developers generally reject fancy Syntax , Choose a clear grammar that doesn't differ .
  • Simple : The code is as easy to understand as pure English .
  • characteristic : All things are objects .
  • stay Python Interactive terminal input import this You can see Python zen

Python Application scenarios of

  • Web application development :Django,Flask,Tornado
  • Operating system management , Server operation and maintenance , Automation script
  • Web crawler :Scrapy
  • Scientific Computing :NumPy,SciPy,Pandas,Matplotlib
  • Desktop software ( Not very mature ):PyQt,PySide,wxPython,PyGTK
  • game
  • Server software ,APP There are also corresponding libraries , It's just that it may not be mature enough and the maintenance is not fast enough .

install Python

download Cpython Interpreter

  • visit Python Official website :https://www.python.org/
  • Click on download Button , Select the system type in the drop-down box ( windows/Mac OS/Linux etc. )
  • Select Download Python3 Version of , Suggest a new stable version

install Ptyhon

  • Double click download okay Python package
  • Check Add Python 3.8 to PATH then Install now
  • Mac and Linux Sure google Installation method , And environment variable configuration .

Test for successful installation

  • open Termal/cmd( The command line ) Input python, If the version number is displayed, the installation is successful ,

    If appear ‘python’ Not an internal or external command , Nor are they runnable programs or batch files .

    Manual configuration is required PATH, take python.exe Installation address of


    Add to environment variables PATH in

Package manager pip Use

  • pip It's a modern , General purpose Python Package management tools , Provide right Python Bag

    lookup , download , install , Uninstall function , Convenient for Python Management of resource packages .
  • install : In the installation Python when , Will automatically download and install pip

pip To configure

  • In the command line , Input pip -V You can see pip Version of .
  • If appear ‘pip’ Not an internal or external command , Nor are they runnable programs or batch files , We need to be the same

    C:\\Users\Eric\AppData\Local\Programs\Python\Python38\Scripts(pip.exe Address ) Add to user PATH In the environment variables .

Use pip management Python package

  • pip install <package_name> Install the specified package , for example : pip install jango
  • pip uninstall <package_name> Delete / Uninstall the specified package
  • pip list Displays a list of installed packages
  • pip freeze And list equally , Just for package==version Format lists

    Packaging and importing environment :
  • pip freeze > requirements.txt Talking about the current environment, all modules are packaged into requirements.txt In file
  • pip install -r requirements.txt install requirements.txt The packages listed in the file

    Modify download source
  • pip install <package_name> -i as follows

    pip install flask -i https://pypi.douban.com/simple/ Download and install from Douban source flask modular

    ( Just temporarily use this Douban source , If not next time -i It's also the default source )
  • Permanent modification pip Download address :

    Create directories and configuration files C:\Users\Eric\pip\pip.ini And edit the following configuration information to save :





    Images are commonly used in China :
  • Alibaba cloud https://mirrors.aliyun.com/pypi/simple/
  • University of science and technology of China https://pypi.mirrors.ustc.edu.cn/simple/
  • douban https://pypi.douban.com/simple/
  • Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
  • University of science and technology of China https://pypi.mirrors.ustc.edu.cn/simple/

    In fact, there is no need to change , A ladder is built by a wall [ funny ]


There are a lot of code editing tools , Yes vim、sublime、notepad++、VS code、Pychram etc.

The last two are recommended as integrated development environments


  • Run on command line py file :python hello.py

Pychram Use

  • Install the professional version directly , Respect copyright and pay ( No more Chinese characteristics or some treasure )
  • Pychram Some of the tips :
  1. Skillfully use . Number , such as a + b.print The carriage return will become print(a+b)
  2. ctrl+shift+k formatting code
  3. ctrl+ Left click the built-in function or module to quickly locate and view python Source code

Interactive programming :ipython

notes -- Help developers read code , A statement that a program will not execute

Single-line comments

# This is a single line comment pychram Shortcut key ctrl+/

Multiline comment

''' So that's one Multiline comment Three single quotation marks for multiline comments '''

Definition of variables

  • For data that is reused and often modified , Can be defined as variables to improve programming efficiency .

The syntax for defining variables

  • Variable name = A variable's value ( there = The function is to assign a value, not equal to )

    for example key = value = True = 1

    a , b = 1 , 3

    a , b = b , a # Exchange assignments

    a , *b = 1,2,3,4,5 # a=1 b = [2,3,4,5]

    python Very flexible , Very clever .

Variable name specification

  1. Cannot use keyword ( Built in keywords into print,if etc. )
  2. You can't start with a number
  3. I want to know the meaning of the name , Underline is recommended
  4. follow PEP8 standard : Variable name , Function names and file names are all lowercase , Use underscores to connect ,

    The class name follows the nomenclature of the great hump ; Constant names are all uppercase .

    The right example :student_name,user_name,user_id...


  • Some identifiers with special functions , Has been python Official use , Developers are not allowed to define the same identifier as keywords themselves .
  • See all the keywords :

    import keyword


    ['False', 'None', 'True', 'peg_parser', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

    None of the above can be named as a new identifier .

data type

  • int plastic
  • long Long integer [ It can also represent octal and hexadecimal ],python3 To be used as waste long
  • float floating-point
  • complex The plural
  • True Boolean type bool, really
  • False Boolean type , false
  • str character string
  • list list
  • tuple Tuples
  • dict Dictionaries
  • set aggregate

View data type

a = "123"

print(type(a)) # type() Return data type

<class 'str'> # This is a string

  • The type does not need to be declared by the developer , Define variables and ,python It's smart enough to help us define types

Output statement

  • Output / Print : Show the object results

    unfinished , Continue in the afternoon ...

【 In seven days Python】day01.Python Environment configuration 、pip、IDE、 notes 、 Variable , data type 、 identifier / keyword 、 Output 、 Enter more related articles

  1. Python selenium chrome Environment configuration

    Python selenium chrome Environment configuration One . Reference article : 1. Make a note of python easy_install and pip Installation address and method http://heipark.iteye.com/b ...

  2. APP Designers get APP The prototype starts , Seven steps APP Design ( turn )

    Any successful APP All need to be based on a solid product concept , Because the concept determines the final completion potential of the product . In general , Deliver it to app Designers are all mobile app Product prototype . Of course, this is after the mobile product manager's deliberation , And have a meeting with you to discuss ...

  3. python+selenium Environment configuration of

    I've written about before python and selenium Add myeclipse Environment configuration of , however myeclipse Too time consuming to start , although myeclipse It has a very good prompt function , But as a beginner , I still use it directly python Of idl ...

  4. Python Study ( One ) install 、 Environment configuration and IDE recommend

    Python Installation . Environment configuration and IDE recommend Official website :https://www.python.org/ edition :2.x and 3.x The difference is bigger :python3 It's not downward compatible : Version differences can refer to the official website As for choice Py ...

  5. Spring boot project maven Of profile Multi environment configuration does not automatically replace variables to solve the problem

    Spring boot project maven Of profile Multi environment configuration does not automatically replace variables to solve the problem   I've been searching online for a long time , The configuration is very simple , But my program just can't automatically replace variables , Finally, it was tested separately , It turns out to be a reference spring b ...

  6. Python Reptiles 2—— Environment configuration

    About the operation of environment configuration , It's very simple , If you don't use a third-party framework , Just install Python You can complete the following operations . One .Python Installation and configuration : windows The installation and configuration process of the system is as follows , If so Mac System , May refer to ...

  7. Python Introduction and environment configuration

    Python  brief introduction Python It's a high-level combination of explanatory . Compilability . Interactive and object-oriented scripting language . Python Our design is very readable , Compared with other languages, English keywords are often used , Some punctuation marks in other languages , It has ...

  8. python Development environment configuration of -Eclipse-PyDev Plug in installation

    install PyDev Two ways to install plug-ins : 1. Baidu search PyDev 2.4.0.zip, Decompress after downloading , obtain Plugins and Feature Folder , Copy two folders to Eclipse Catalog , Cover can . The version of the plug-in should correspond to py ...

  9. Python Flask Multi environment configuration

    Python When I get the configuration file from the , It was used before ini Document and python in configparser modular : May refer to :https://www.cnblogs.com/feeland/p/4514771.ht ...

  10. Python Sandbox environment configuration

    One . brief introduction This article describes configuration python The method steps of sandbox environment . Two . Installation steps 1. install pyenv http://www.cnblogs.com/274914765qq/p/4948530.html 2. install v ...

Random recommendation

  1. Android--WebView Control

    WebView One brief introduction : WebView It is generally used for Android The page is closed HTML In the form of , We usually call it HTML5 Development : WebView It makes it easy to embed web pages into app in , You can also talk to js Mutual invocation , adopt ...

  2. MPLS VPN Lecture notes 2

    In depth understanding of ospf understand MPLS VPN Chinese vs OSPF The supplement of hierarchical design supper backbone area 2: understand MPLS VPN in OSPF The concept of regional design 3: understand MPLS VPN in OS ...

  3. Move App Ten suggestions for design

    Link to the original text : 10 Key Design Tips for Great Mobile Apps Original date : 2014 year 03 month 24 Japan Translation date : 2014 year 04 month 01 Japan Use Android and iOS Write a ...

  4. Oracle Flashback table

    Oracle Flashback Technology scene : The table data in the test environment database was deleted by mistake . Solutions : Using flashback table technology principle Flashback technology is Oracle Part of a powerful database backup and recovery mechanism , When a logical error occurs in the database , Flashback technology provides fast and minimal ...

  5. java Basics - development tool IDEA

    Common shortcut key lookup lookup :Ctrl + F Find In Path: Ctrl + F + Shift ( One more than ordinary search shift) Search EveryWhere : double-click Shift View ...

  6. hibernate(*.hbm.xml) The newly added fields in are marked in red ( Can't find ) Solutions for

    First of all, it has to be generated in this way bean and xml, Configure the data source ( In this way, we can make hibernate Configuration and mysql Interact ) https://www.cnblogs.com/kinome/p/10549969 ...

  7. scrollview nesting recyclerview The Caton phenomenon

    Mode one xml: android:nestedScrollingEnabled="false" <android.support.v7.widget.RecyclerView ...

  8. OpenSSL Self signed certificate

    Through the following 9 Step , Self signed certificates can be easily generated . 1. install . Deploy OpenSSL A little 2. Create folder ( The following is usually root Folder ). It is used to put all kinds of certificates to be created . Such as :I:\Key10.167.219.64 3. stay roo ...

  9. Sqoop Import relational database to Hive

    Reference resources :segmentfault.com:Sqoop Import relational database to Hive Sqoop yes apache It's used for RDBMS and HDFS A tool to export data to each other . This article takes mysql Database, for example , The number of realized relationships ...

  10. 2014 ACM/ICPC Anshan District network competition ( Tsinghua proposition )

    To welcome 10 month 17 Anshan live match of Tsinghua proposition Hang Dian's topic Biconnected(hdu4997)      State compression DP Rotate(hdu4998)     Rotation relative to any point Overt(hdu4999 ...