python--Basic Knowledge

Source: Internet
Author: User

1.python is an interpretive, object-oriented, high-level programming language with dynamic semantics.


2.python advantages
★ founder Rating: Simple, elegant, clear
     ° is simply reflected in if your native language is English, writing a python script is like writing an article, very simple;
    ° elegant in python format, such as indentation to determine the code block, to avoid the programmer to do complex nesting; The
    ° clearly shows only one of the best options for solving the problem, while the Perl language is the most optimal solution for every problem. But not conducive to team collaboration;
★ There are powerful third-party library modules that need to implement a complex function that requires only the invocation of an existing library to quickly implement functionality. More than 20 years of development, all kinds of libraries have been completed
, such as: Mail library, crawler library ...
★ can be ported across platforms, Java has Java virtual machines, Python is the same;
★ is an object-oriented language;
★ is an extensible language (combined with C,c++,java)
3.python disadvantage
★ code execution is slow, compared to the C language, but now Python's asynchronous concurrency framework results in slow execution;
★python is an open source programming language, code cannot be encrypted, and of course there are tools to convert Python code to exe binary executable code, but the anti-decoding is also easy;

Application of 4.python

Software development: Game backstage, search, graphical interface, website, Scientific computing
System Management: Scripting, it automation tools

5. Install Python:

650) this.width=650; "src=" https://s3.51cto.com/wyfs02/M02/9B/96/wKioL1lkswDxIp9RAACWvoA0-zg107.jpg "style=" float : none; "title=" 36020170711184931640.jpg "alt=" Wkiol1lkswdxip9raacwvoa0-zg107.jpg "/>

6. View the Python version

Python-v View Version

Python uses Python interactively

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9B/96/wKioL1lks7_xZYmOAACc3Zx-DO8646.jpg "title=" 36020170711191701633.jpg "alt=" Wkiol1lks7_xzymoaacc3zx-do8646.jpg "/>

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9B/B3/wKiom1ll-nzTSdIdAAApNnEiEAw443.jpg "title=" 36020170712183043946.jpg "alt=" Wkiom1ll-nztsdidaaapnneieaw443.jpg "/>7. python script file

650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M01/9B/B3/wKiom1ll_gjQmgRyAACYJaL9eaY543.jpg "style=" float : none; "title=" 36020170712184529732.jpg "alt=" Wkiom1ll_gjqmgryaacyjal9eay543.jpg "/>

#!/usr/bin/python # # directly refers to the default python version of the system , so the python program is ported It may be problematic to run on other machines because the default Python version of someone else's system is inconsistent with what you expected.

#!/usr/bin/env Python # # referencing environment variables inside the custom python version , with strong portability

650) this.width=650; "src=" https://s1.51cto.com/wyfs02/M01/9B/B3/wKioL1ll_gnjHoCpAABbul06GtM220.jpg "style=" float : none; "title=" 36020170712184609835.jpg "alt=" Wkiol1ll_gnjhocpaabbul06gtm220.jpg "/>

# #代码里有中文时编码时设置编码格式#coding: Utf-8

* * #coding: Utf-8 # #设置编码格式

Four different encoding formats:

#coding: Utf-8
#coding =utf-8
#encoding: Utf-8
#encoding =utf-8


8.python common tools


Command: Ipython # #交互式使用python软件

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9A/0C/wKioL1lQtdXw41lWAADVzI5_bWw263.png "title=" ~l] E8JP) VK@GC) 8IV ' D) h2p.png "alt=" Wkiol1lqtdxw41lwaadvzi5_bww263.png "width=" 650 "style=" padding:0px;margin:0px; Vertical-align:top;border:none; "/>

Command: Pycharm # #启动python软件

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9B/B2/wKioL1ll-_jQTFD6AAGcNWHhZv4983.jpg "title=" 36020170712183703825.jpg "alt=" Wkiol1ll-_jqtfd6aagcnwhhzv4983.jpg "/>

9.the difference between Python and C scripts


650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9B/B3/wKioL1lmA0OhGHvmAAAcjW-ia_k430.jpg "title=" 36020170712190810050.jpg "alt=" Wkiol1lma0ohghvmaaacjw-ia_k430.jpg "/>

Python script

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9A/0C/wKioL1lQtJyhVPsfAAAW6VBj6oA535.png "alt=" Wkiol1lqtjyhvpsfaaaw6vbj6oa535.png "/>

C file

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/9A/0C/wKioL1lQtL6hP4R5AAAVn4EEs9U648.png "alt=" Wkiol1lqtl6hp4r5aaavn4ees9u648.png "/>

Test:

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9A/0C/wKioL1lQtUXRLwOGAAAzT8T2PsI414.png "alt=" Wkiol1lqtuxrlwogaaazt8t2psi414.png "/>

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9A/0C/wKioL1lQtVHRBm7WAABdcnc4yr4597.png "alt=" Wkiol1lqtvhrbm7waabdcnc4yr4597.png "/>

python comments

* * Single comment : # is often used as a single-line comment symbol, # any data on the right side of the line that begins is ignored as a comment.
* * Block Comment : Use a three-quote "" When you need bulk text or code . And, of course, three quotation marks can also be used to achieve multi-line text format printing.

Understanding character Encoding


650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M01/9B/B3/wKioL1lmCDzyqvJbAABC4M81ksU852.jpg "style=" float : none; "title=" 36020170712185056691.jpg "alt=" Wkiol1lmcdzyqvjbaabc4m81ksu852.jpg "/>

650) this.width=650; "src=" https://s4.51cto.com/wyfs02/M02/9B/B4/wKiom1lmCD3j0PnZAAA1VZpKU08818.jpg "style=" float : none; "title=" 36020170712185120498.jpg "alt=" Wkiom1lmcd3j0pnzaaa1vzpku08818.jpg "/>


650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9B/B4/wKiom1lmCKzBPMHnAAB6xdxEt_U330.jpg "title=" 36020170712193142452.jpg "alt=" Wkiom1lmckzbpmhnaab6xdxet_u330.jpg "/>
12. Encoding and decoding of characters

* * When storing data to the hard disk, need to take into account space-saving problems, so in the utf-8 format for storage;
* * When the data is read into memory, unified one encoding format for easy operation, in Unicode encoding format;
* * Therefore the character encoding and decoding must be skilled operation.

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/9B/B4/wKioL1lmFInjfUkMAACRBRtywI4421.jpg "title=" 36020170712202216141.jpg "alt=" Wkiol1lmfinjfukmaacrbrtywi4421.jpg "/>

python--Basic Knowledge

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.