1: Shaping
#十进制
1Print 12 13Print -14 -15print 06 07 >>>
1 >>> # 16 binary starts with 0x, 0-9,a-f,a-f ... 3 >>> print 0xa4 105 >>> print 0xa< Span style= "color: #008080;" >6 107 >>>
1 >>> # 2 binary starts with 0b, 0 and 1 2 ... 3 >>> 0B01 4 15 >>> print 0b01 6 1
# 8 binary starts with 0, 0-7 ... >>> 0011>>> 000011>>> 0119>>> 07763>>> 078 " <stdin>", line 1 0 ^syntaxerror:invalid tokenprint ' 011 ' # if it is the data that represents the beginning of semantic 0, you can use the string 011>>>
2: Floating-point type
1 #2: Floating point type.21. Is the number with the decimal point32. Control the number of digits of the output floating-point numbers4 #Formatting Strings5>>>Print "%.2f"%a61.227>>>Print "%.4f"%a81.22209>>> B ="%.4f"%aTen>>>b One '1.2220' #string A #Math's ceil (x) function and math's floor function - #ceil (x) rounding up ->>> fromMathImportCeil,floor the>>> Ceil (2.75) -3.0 ->>> Ceil (2.17) -3.0 +>>> - #Floor (rounded down) +>>> Floor (1.75) A1.0 at>>> Floor (1.17) -1.0 ->>> B = Floor (1.17) ->>>Printb -1.0 ->>>b in1.0 - #Forced Conversions to>>> Int (1.72) +1 ->>> Int (1.17) the1 *>>> $ Panax Notoginseng #round function - #the round function of 2.x and 3.x is different, 3.x version http://www.cnblogs.com/herbert/p/3402245.html the #do not specify the number of bits parameter + A the #but the 2.7 is followed by rounding. +>>> Round (0.5) -1.0 $>>> Round (0.7) $1.0 ->>> Round (0.4) -0.0 the>>> Round (2.5) -3.0Wuyi>>> Round (3.5) the4.0 ->>> Round (4.5) Wu5.0 ->>> Round (4.4) About4.0 $ - #specify the number of bits parameter - #adjust the position of the decimal point, and then rounding ->>> Round (4.49999999, 0) A4.0 +>>> Round (4.49999999,1) the4.5 ->>> Round (4.49999999,2) $4.5 the>>> Round (4.49999999,4) the4.5 the>>> Round (4.49999999,-1) the0.0 - in #high precision using the decimal module for use with GetContext the>>> fromDecimalImport* the>>>Print(GetContext ()) AboutContext (prec=28, Rounding=round_half_even, emin=-999999999, emax=999999999, CAPI theTals=1, flags=[], traps=[Overflow, InvalidOperation, Divisionbyzero]) the the>>> GetContext (). Prec = 10 +>>> B = Decimal (1)/decimal (3) ->>>Printb the0.3333333333Bayi>>> the the>>> B =GetContext () ->>> B.prec = 3 ->>> C = Decimal (1)/decimal (3) the>>>PrintC the0.333 the the>>> A = 1.3 ->>> B = 1.7 the>>> C = Decimal (a)/Decimal (b) the>>>PrintC the0.765
3: String
1 #3: String Analysis2The string is in"'And""any text enclosed in3>>>'a',"b"4('a','b')5>>>6When"'And""you need to escape the character itself as a string.7>>>'Hello, I\ ' m Lip'8 "Hello, I ' m Lip"9>>>'Hello, i\ ' m \ "Lip\"'Ten 'Hello, I\ ' m "Lip"' One>>>
4: null value
A null value is a special value in Python, with none, which means it is not 0,0.
5: Boolean value
Only true and false two forms (note that the first letter is uppercase, Python is case-sensitive)
An and (and) or (or) not (non) operation can be performed between Boolean values
A few of the values are false:false,none,0, "", (), [],{}
Python's underlying data type