Transfer and storage of Python internal files

Source: Internet
Author: User

1.name = "Alex"
Print (ID (name))
Li = [a]
Print (ID (LI))2.is determines the memory addressName1 ="[email protected]"name2="[email protected]"Print(name1 = =name2)Print(name1 isname2)in Pycharm, 2 of the results are true .in the Python small black box, print (Name1 is name2) false 3. Small Data pool
in Pythonint STR has small data poolint-5-----Str
If it's all a string of letters, it's pointing to a memory address
If the number is multiplied by str (single letter), the same memory address is within 20 (inclusive)other data types, there is no small data pool concept4.S1 = "Alex"s2 = "Alex"
Q: Will changing s1,s2 change?
A: strings, tuples, and int are immutable data types. DIC will change. 5.Unicode: Universal code (default = 32 bits is a single character)
a:0000 0001 0000 0001 0000 0001 0000 0001
medium: 0000 0101 0000 0101 0000 0101 0000 0101Upgrade: Utf-8: Use at least 8 Wei to represent one character
a:0000 0001 8-bit
Europe: 0000 0001 0000 0001 16-bit
Medium: 0000 0101 0000 0101 0000 0101 24-bitGBK: GB
a:0000 0001 8-bit
Medium: 0000 0101 0000 0101 16-bit1. Different compilation between each other can not identify the other side of the binary, will error, or generate garbled
2. In your string (file) storage, transfer, you must use a non-Unicode binary (01010101)
6. Data type(1) bytefor non-Chinese: representation: B "Alex"
Internal code: utf-8,gbk,gb2312 ... (Non-Unicode) you set thefor Chinese: representation: B "Xe3\xf2\x36\xe3\xf2\x36\"
Internal code: utf-8,gbk,gb2312 ... (Non-Unicode) you set the(2) Strfor non-Chinese: presentation: "Alex"
Internal code: Unicode
 
Internal code: Unicode     


7. Representation and Conversion
Encode is a representation converted into Utf-8 g format
(1) English representation and conversions ="Alex"b= S.encode ("Utf-8")Print(S,type (s))Print(B,type (b))#(2) Chinese representation and conversions ="I love China"b= S.encode ("Utf-8")Print(S,type (s))Print(B,type (b))

Transfer and storage of Python internal files

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.