Python Beginner Notes

Source: Internet
Author: User

Declaration of a variable:

The first character of a variable name cannot be a number,

Consists of letters, numbers, underscores

Avoid using keywords when declaring variables

Assignment of variables:

Assignment of variables: variable = ' content '

name1= "Content"

Name2= name1 (just assign the memory address that name1 points to name2)

--

name1 = ' Syl '

Name2 = name1

Output name1 and name2, output is Syl

Modify NAME1 Content

name1 = ' 123 '

In the output name2, the content or ' syl ' has not changed

Note: When re-assigned to NAME1, the original memory stored in the address content has not changed, but in memory to re-open a memory space to store new content, so the value of content 2 or point to the original memory address, so the output is name1 original content

! String attribute:! Once modified, recreate the memory space

Cases:

"Hello" + ' SB ' + ' Alex '

This situation takes up 3 blocks of memory space

"Hello"

"Hello" + ' SB '

"Hello" + ' SB ' + ' Alex '

Garbage collection mechanism for virtual machines: virtual machines are always running, automatic garbage collection mechanism, developers do not care about memory consumption and release

How many stages does a python file need to go through?

1. Loading memory, lexical analysis, parsing, compiling--bytecode--Execute byte code, generate machine code

2, byte code: ASCII, Unicode, Utf-8

3. argv built-in module

4. Default digital buffer pool size: -5~257

Process Control:

Process Control: 1.if else,if After comparison, you must write a colon: Indicates the end of the statement, if there is no curly brace in Python, you need to note

2. Multiple judgments can write else if if elif

Writing code in Python must be aware of indentation


Python Beginner Notes

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.