Python Learning Day6

Source: Internet
Author: User

Yesterday review

Dict:dic = {'name':'Alex'} added: dic[' Age'] = 21presence on overwrite Dic.setdefault () does not increase Delete: Pop () is deleted by key, with return value cleardeldic['name'] Popitem () random delete returned is Ganso update Dic.keys () dic.values () Dic.items () forKvinchDic.items ():Print(k,v) dic.get (key,none)

Coding issues

ASCII A:000000108-bit one-byte Unicode a:00000000 00000001 00000010 0000010032 bits in four bytes:00000000 00000001 00000010 0000011032-bit four-byte UTF-8 a:001000008 bits in one byte:00000001 00000010 0000011024-bit three-byte GBK A:000001108 bits in one byte:00000010 0000011016 bits Two bytes1, the binary between each encoding, is not mutually recognized, will produce garbled. 2, file storage, transmission, cannot be Unicode (only utf-8 utf-16gbk,gb2312,asciid, etc.) PY3:STR is encoded in memory in Unicode. Bytes type for English: str: Presentation form: S='Alex'Encoding Method:010101010Unicode Bytes: representation: S= b'Alex'Encoding Method:000101010 Utf-8GBK .... For Chinese: str: Expressive form: s='China'Encoding Method:010101010Unicode Bytes: representation: S= b'x\e91\e91\e01\e21\e31\e32'Encoding Method:000101010 Utf-8 GBK

Summary of small knowledge points

= Assignment = = Comparison value is equal isCompare, the memory address ID (content) is compared#li1 = [A]#Li2 = Li1#Li3 = Li2#Print (ID (LI1), ID (li2))#Numeric, string small data pool#range of Numbers-5--#string: 1, cannot have special characters#2,s*20 is still the same address, and S*21 is two addresses later.#I1 = 6#i2 = 6#Print (ID (i1), ID (i2))#I1 =#i2 =#Print (ID (i1), ID (i2))#The remaining list dict tuple set#L1 = [1,]#L2 = [1,]#print (L1 is L2)#s = ' Alex '#S1 = B ' Alex '#Print (S,type (s))#Print (S1,type (S1))#s = ' China '#Print (S,type (s))#S1 = B ' China '#Print (S1,type (S1))S1='Alex'#encode encoding, how to put str---Bytes, ()S11 = S1.encode ('Utf-8') S11= S1.encode ('GBK')Print(S11) S2='China'S22= S2.encode ('Utf-8') S22= S2.encode ('GBK')Print(S22)

Python Learning Day6

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.