python data type of operation (numbers, strings, lists, tuples, dictionaries, set)

print (bin (16)) # Binary Decimal transfected 0b10000 
Print (hex (15)) # Hex Decimal transfected 0xF
# string operations
print ( 'Age:% d, Name:% s'% (18, ' Zhu ')) #% d,% s using
Print (type (' ASF ')) # <class' STR'>
name = 'ABCD *** * EFG AD'
Print (name.strip ( '*')) # the effect is to remove the function at the beginning and end of a specified string of characters, the character is not removed the corresponding intermediate string;
# if incoming character string is removed and a space at the beginning or end of line character default; if incoming character, the character will be based on the incoming removal operation;
Print (name.split ( '*',. 1)) # sliced by specifying the string delimiter, if num parameter value is specified, then the partition num + 1 substring
STR = 'abcdabcd'
Print (str.find ( 'a',. 1, len (STR))) # find characters start, end returns the index found in the first
print ( ':'. join (STR)) #a is: B: C: D: A: B: C: D

# a list of actions
dict = {
'Age': 20 is, 'name': 'su'
}
print(dict.keys())
print(dict.values())
Print (dict.items ())
Print (dict [ 'Age'])
for K in dict:
Print (K, dict [K])

S = 'Li'
Print (s.encode ()) #puython default utf-8 decoding the encoded
'' 'python mechanism for the string str when read from the display memory, Python automatically decoding work is a string of binary not see,
but which according to the binary string corresponding unicode characters, but for bytes bytes is, python will not deal with him, so authentic presented to you,
so what you see is a string str and bytes are hex binary representation. '' '

Guess you like

Origin www.cnblogs.com/a19960101/p/11854771.html