Python day-3 basic data types

Source: Internet
Author: User

1. Encoding
1. The earliest computer encoding is ASCII. Created by Americans. Contains the English alphabet (uppercase letters, lowercase letters). Special characters such as numbers, punctuation, etc. [email protected]#$%
128 code point 2**7 on this basis added a 2**8
8 bits. 1 bytes (byte)
2. GBK GB code 16 bit. 2 bytes (double-byte characters)
3. Unicode universal Code 32 bits, 4 bytes
4. Utf-8: English 8 bit 1 bytes
European Writing 16bit 2 bytes
Chinese 24bit 3 bytes

8bit = 1 byte
1024x768 byte = > 1kb
1024x768 = 1MB
1024MB = 1GB
1024GB = > 1TB


2. Overview of basic data types
int integer
STR string, storing a small amount of data
BOOL Boolean
List, ["Tai Yang elder brother", "Dongyang elder brother",]
Tuple tuples. Read-only list, cannot be changed
Dict dictionary; A pair of stored data. Key:value {"Zhao Yang": "Tai Yang elder brother", ' Jay ': "Jay Chou"}
Set set. Store non-duplicated content

3. int, bool, str
int method Operation:
Bit_length () to find the binary length
BOOL: type conversion
1. What you want to convert into. Just wrap the target with something.
2. Null is False, true without empty
Str
1. Str indexes and slices:
Index: Starting subscript is 0 (left to right), (-1) right to left
Slice: s[start position: End Position: Step]
Features: Gu Tou regardless of the tail

2. Common operations for strings: common methods
The string is immutable.
1. Upper () converted to uppercase
2. Strip () Remove space
3. Replace () replacement
4. Split () cut
5. Format () formatted output
6. StartsWith () Decide whether to start with XXX
7. Find (). No return-1 found
8. Len () built-in functions. Direct use. To find the length of a string without a point operation
3. Iteration
The for variable in can iterate over the object:
Loop body
Else

Python day-3 basic data types

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.