python development [first article]

  1. Content encoding When the python interpreter loads the .py file, it encodes the content (ascii encoding by default).
    ASCII is a computer coding system based on the Latin system. It is mainly used to display modern English and other Western European languages. It can only be represented by 8 bits at most (one byte), namely: 28=256, so ASCII is the most It can represent 256 symbols.
    Obviously, ASCII cannot represent all the languages and characters in the world, so a new character encoding is needed, namely Unicode.
    Unicode (Uniform Code, Universal Code, Single Code) is an encoding used on computers. Unicode was created to solve the limitations of traditional character encoding. It sets a uniform and unique binary encoding (and ultimately, binary encoding) for each character in each language. It is stipulated that all characters and symbols are represented by at least 16 bits (1 bit is 2 bytes), which is 2
    16=65536.
    UTF-8 is the compression and optimization of Unicode code. Instead of using at least two bytes, it classifies all characters and symbols: the byte in the ascii code is represented by one byte, and the European symbols are represented by two. Byte representation, East Asian characters are represented by three bytes. . . .
    So when the python interpreter loads the .py file, it encodes the content, and the default is ascii encoding. If the code is as follows and Chinese characters appear, the encoding will fail.
    Failure: The ascii code cannot represent Chinese.
    Correction: It should be displayed to tell the python interpreter what encoding to use to execute the source code, namely:
    #! /usr/bin/env python # -- coding: utf-8 -- print "Hello, world"
1 #! /usr/bin/env python
23 print "Hello world"
  1. Execute script and pass in parameters
    Python has a large number of modules, which makes the development of Python programs very concise. The class library includes three:

Python provides a sys module, where sys.argv is used to capture the parameters passed in when executing the python script

/usr/bin/env python # -- coding:utf-8 -- import sys args = sys.argv print(args)

Results of the:
[' D:/PycharmProjects/test/test08.py','Zhang San','Li Si','Wang Wu']

  1. Usage of getpass in python The function of getpass in python is to enter the password invisible to open the terminal of pycharm

Recommended Posts

python development [first article]
ubuntu build python development environment
Python3 interface development commonly used.md
Use of Pandas in Python development
Python embeds C/C++ for detailed development
Use of numpy in Python development
Real zero basic Python development web
Python business card management system development
Learning path of python crawler development
CentOS 7 configure Python language development environment
A complete guide to Python web development
What are web development frameworks in python
What is the prospect of python development
Build a python development environment under Ubuntu
Quickly understand the Python development environment Spyder
A first look at Python regular expressions (6)