Python_day1 python basics, python_day1python

Source: Internet
Author: User

Python_day1 python basics, python_day1python
My profile

QQ: 987704751

Email: huzi3652297@qq.com

Introduction to Python (English pronunciation:/ˈ pa θ ə n/American pronunciation:/ˈ pa ɪ θ ɑ n /), it is an object-oriented interpreted computer programming language. It was invented in 1989 by Guido van rosum, a Dutch user. The first public release was released in 1991. Python is purely free software. The source code and interpreter CPython follow the GPL (GNU General Public License) Protocol [2]. The Python syntax is concise and clear. One of its characteristics is to force the white space to be used as the statement indent. Python has rich and powerful libraries. It is often called the glue language, and can easily connect various modules (especially C/C ++) made in other languages. A common application scenario is to use Python to quickly generate a prototype of a program (sometimes even the final interface of the Program) and then have special requirements for [3, rewrite with a more appropriate language. For example, if the graphic rendering module in 3D games has high performance requirements, you can rewrite it with C/C ++ and encapsulate it as an extension class library that can be called by Python. It should be noted that you may need to consider Platform issues when using the extended class library, and some may not provide cross-platform Python implementation.

My job before learning python is a small O & M. I have experienced all kinds of sadness in the O & M work. I think my O & M colleagues have a deep understanding, which is commonly known as the "pan Xia" in the company '. So, in order to get rid of this kind of manual O & M dilemma, and thus to improve myself, I have made up my mind. It is necessary to learn python well, after many inquiries and peer introductions, I chose to go to the old boy Education and Worship the Alex King as the teacher. Under the cool education of the King, I began to embark on the python Road, I have been learning python for a while. Today I want to sort out the learned knowledge so as to consolidate my own knowledge and share what I learned with you, I have a general learning ability, so please do not mean your little skills when you make some mistakes in the subsequent introduction of python. Despite your free speech, I will certainly learn from you. I wish you all the colleagues who are learning python a smooth job. The more code you write, the more cool you are.

  O & M that won't be developed will eventually be eliminated !!!

Why python?

  Easy to use, high development efficiency, and python is a full-stack language, as the most important language for O & M development, many popular automated O & M tools are developed based on python, such as openstack, ansible, and so on. Python has become increasingly popular since it was developed.

Python environment deployment

Python official: https://www.python.org/downloads/

You can select a system version to download based on your environment.

The installation steps are omitted here

All articles are based on python3.X

Python's first program

In international practice, write a hello world first! Haha

Create a hello. py file in Linux or windows and write the following code:

print('hello world!')

  

 

Run python hello. py

G:\>python hello.pyhello world!

OK! Congratulations, you will already use python.

Variables and naming rules Soft Regulations

In python, you can directly write the variable name by calling the variable.

>>> name = 'alex'>>> msg='hello'>>> print(msg,name)hello alex

  

 

Character encoding

  Ascii code, One character occupies one byte

  

The smallest computer unit is bit.

Minimum storage unit: 8 bits = 1 byte = 1 byte

  Unicode:One character occupies two bytes

  UTF-8:The content in the ascii code occupies one byte, the European character occupies two bytes, and the East Asian character occupies three bytes.

Data Type Number

Int integer)

Long Integer

Float (decimal number)

Complex (if you are interested, you can study it and I rarely use it)

Boolean Value

True: True. The condition is True.

False indicates False. The price adjustment is not valid.

String

  Remove blank:Strip (). When this attribute is used, the interpreter removes spaces from the string,Returns a new value.  

 

>>> name='    alex  '>>> name'    alex  '>>> name.strip()'alex'

 

  

 

 

 

 

Length: len () to determine the length of a string.

 

>>> name'    alex  '>>> len(name)10

  

 

Slice: Part of the string. The features of Slice:Gu tou disregard the tail

>>> name='alex'>>> name[0:2]'al'

Format output

>>> name='alex'>>> age=12>>> msg='name is %s ,age is %d'%(name,age)   >>> print(msg)name is alex ,age is 12

  

 

 

 

  

  

  

  

 

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.