Basic data types
1, integral type (int)
2. String (str)
- How to create
S1 = "Hello" s1 = str (' Hello ')
String (str) type and bytes type convert py3 version
STR (bytes_or_buffer[, encoding[, errors]), str
Name = "Blog Park" for I in Name: print (i) bytes_list = bytes (i, encoding= ' utf-8 ') print (bytes_list) # By default each byte is 16 binary for the X in bytes_list: print (X,bin (x)) # Default Every byte is a 10 binary representation
Because of the utf-8--3 bytes
GBK--"2 bytes
Output Result:
Bo B ' \xe5\x8d\x9a ' 229 0b11100101141 0b10001101154 0b10011010 guest B ' \xe5\xae\xa2 ' 229 0b11100101174 0b10101110162 0b10100010 Park B ' \xe5\x9b\xad ' 229 0b11100101155 0b10011011173 0b10101101
- Binary conversions such as:
PS: General string execution of a function will generate a new content, the original content is unchanged list,tuple,dict.
3. Dictionary (dict)
- Small case, take out 123 in the dictionary:
Li = ["Alex", 123, {"K1": "V1", "K2": {"VV": (11,22,123), "II": 456}]Print (li[2][' K2 ' [' VV '][2])
Python Basic Series One: First knowledge python (ii) supplements