# About python knowledge summary # some differences 1.python2 and python3 of # python2 default ascii coding, python3 default utf-8 encoding, python2 can be added in the first line # - * - encoding: utf- 8 - * - solving # python2 of raw_input may be input into an expression, but after python3 directly into the default input string is not performed # python2 brackets can output print, may not be added, but must python3 brackets # python2 range and has xrange (Builder ), only to python3 Range # 2. iS = == # assigned memory address comparison # assignment operator, two variables to the same memory address # a = 100 # B = a # Print (ID (a), ID (B)) # saving 3. small data pool, to a certain extent the memory space # numeric string (small data pool), other types of lists, tuples, dictionaries (data not smaller pools) #Small data pool, if between -5 and 256, the address is the same (but I see pycharm all the same, as long as the same value, cmd is not the same as more than 256) # string: can not contain special characters # S * 20 is an address, * 21 is not the same address # S1 = 'a' * 20 # S2 = 'a' * 20 # Print (S1 iS S2) # returns to true # a = 3000 # B = 3000 # Print (ID (a), ID (B)) # a = 400 # Print (ID (a), ID (B)) # 4. encoding: ascii byte eight, English, numbers, special characters # Unicode 32 bits of the word section, regardless of the language # UTF-eight one byte. 8 English, Chinese 24 24 byte, 32-bit 4-byte text European # GBK 8 English one byte, two-byte 16-bit Chinese # between individual coding binary is not recognize each other, may be garbled # Storage file transfer, can not be uniccode (only utf-8, utf-16, gbk, ascii , etc.) # # STR in memory is stored in unicode encoding, transmission and storage # bytes type, but also a special data type, or with other gbk utf-8 or ASCII # STR enough bytes transmitted is converted into stored unicode-> other # English: # STR: manifestation is 'asf', encoding is Unicode string 01010 # bytes: expressions is b'asf ', encoding a string of 101010 utf-8, gbk the like (not interworking between individual coding) # Chinese: # STR: expressions' in', encoding a string of 0101 # bytes: s form of = b '\ xe4 \ xb8 \ xad' represents a minimum three Chinese section (s = b 'in' being given definitions) # S1 = 'ASR' # S2 = b'asr ' # Print (S1, type (S1) ) #print (s2, type (s2) ) # returns bytes # # S3 = 'Chinese' # S4 = s3.encode ( 'GBK') # Print (S4) # Returns b'asd ' # 5. The simple arithmetic operation # + - * / **%