程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Getting started with python (must be able to start)

編輯:Python

python Interpreter

  • A compiled : Compile source code into machine language (0101), And save as binary file , The runtime computer runs the binaries directly ( benefits : Fast execution , shortcoming : Cross platform compatibility ,windows Executable documents ,Linux Unenforceable , Recompile every time you change the code )【C Language ,Go Language 】
  • interpreted : Equivalent to an interpreter , Execute the source code directly , Translate while executing , While executing ( benefits : Simple and clear , Good cross platform compatibility , As long as there is a compiler , shortcoming : Inefficient execution )【python,Java】
  • notes :Linux The default interpreter for is bash
  • python Interpreter type
    1、 Cpython: The default is Cpython Interpreter , c Language implementation ( advantage : official 、 Treasury )
    2、 IPython: be based on CPython An interactive interpreter on top ( beautiful 、 Can be realized bash、shell compile )
    3、Jpython:java Realization , Python The code will be converted into Java Bytecode
    4、IronPython:c# Realization
    5、PyPy:python Realized python Interpreter pypy High operational efficiency ( advantage :JIT technology : With cache function : Compiled code , Don't recompile )
    Interactive environment : Type one line of code and execute one line of code ( Equivalent to wechat chat )
python Prompt

>>>: type python The main prompt for the statement
···: Secondary prompt ( Add at the end of the line \ : Line continuation operator ) Generally, it means that the statement does not end , No input completed

python Assignment
  • Direct assignment :a = 1 a = “ok”
  • Continuous assignment :a = b = 2
  • Multiple assignment :name,sex=‘zjh’,‘female’
  • Assignment interchange :a,b = b,a
    notes : All code is copied from disk to memory for execution
python notes

Single-line comments :#
Multiline comment : Three pairs of ( single ) quotes
notes :pycharm in : Whole block comment :ctrl+/

python Rule of grammar :

Code segment : Indent to distinguish code segments ( It is suggested that 4 Space to indent (pythonic))
Line break : Carriage returns , At the end of the line, you can add ";"
Line continuation : End of line “"
Write multiple statements on one line : use ";" branch

see python edition :python -V
see pip route :pip -V
Installation tools :pip install Library name (ipython)
( notes : stay Linux The version and model shall be indicated :python3 -V)

python Several built-in functions in
  • id: View the memory address of the object (id(a) or print(id(a))
  • help: View object help information
  • dir: View the properties and methods of the object (dir(a): among center Usage method :
    #print(name.center(20,"*"))# The length is 20,name In the middle , use * fill )
  • type: View the type of object (int/str)

python One of the most popular IDE:pycharm

PyCharm Common shortcuts
• Ctrl + suspension / Click the left mouse button : brief introduction / Enter code definition
• Ctrl + /: Line notes / Cancel line comment
• Ctrl + Shift + / : Block annotation
• Ctrl + Alt + L : Code formatting
• Ctrl + D : Copy selected area or row
• Ctrl + R: Replace
• Shift+F10: function

User input :input

pycharm Set the display format ( typeface 、 Background, etc )
Set the code font size 、 Setting of line spacing
pycharm Background color 、 Font, etc
python script Setting template for , Declarable author 、 Creation time 、 file name 、IDE etc.


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved