Python Basics 06 Coding and small Knowledge points supplement

Source: Internet
Author: User

The main contents of this section :

< Span class= "Fontstyle1" >1. Is== the difference
2. encoding problem

? difference between. is and = =
1. ID ()
by ID () we can see the value of the variable table? The address in memory

Note----<<< in python , command? Code and py? The effect of the code shipped in the piece may not be a kind of >>>

SaidWith so much.This oneID ()AndIsWhat's the matter?System?.Attention. Is? moreIs thatID ()The calculated results.Byid Yes, help me.
View data () memory address so is more ( object The memory address most finally we pass is two No

== Double- Judge No et note this double-and so on < Span class= "Fontstyle3" > ? Not memory address < Span class= "Fontstyle3" >

Total Knot :
is more ==

? encoded supplement
1. Python2 silent Yes yards so python2 more coded need to be in the beginning of the piece write :
#-*-Encoding:utf-8-*-

2. Python3 : The Unicode code is in the memory.

Encode backGu:
1.ASCII:EarliestThe encoding.??YesBritish?? writeWord?,?WriteWord?,Digital,?SomeSpecial characters.Not in?,
8A01Code, 8Abit, 1AByte
2.GBK:In?GbCode,?? containsTheAsciiCoding and medium-constant encoding. 16ABit, 2AByte
3.UNICODE:MillionCountryCode,?? containsTheWorldAllCountriesThe encoding of the word. 32ABit, 4AByteContainsThe
Ascii
4.UTF-8:Variable? degreeThe MillionCountryCode.IsUnicodeKind of reality . the most, the character occupies 8 bits.
1. English : 8bit 1byte
2. European Word : 16bit 2byte
3. in? : 24bit 3byte
in addition to ASCII code , other information cannot be converted directly .

InPython3In-memory.InRideOrder shipment?Stage.What makes the?UnicodeCoding.BecauseUnicodeis millionCountryCode.What inside
Can we go in?Explicitly?.So in the dataMass transferWhen you lose and store.ByInUnicode? More wasted SpaceAndResources.Need to put
UnicodeDump intoUTF-8OrGBKinto storage.HowWhat about the conversion?.InPython encode After the content can be entered? lost code . Its also original Data is just coded After performance form hair?

RememberLive: coding results and source string? To The results are based on different coding coded result
also differs we can see utf-8 encoding Yes 3 bytes gbk The encoding is 2 bytes .

Python Basics 06 Coding and small Knowledge points supplement

Related Article

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.