A string formatting
Placeholder%s and%d
%s is a placeholder for a string, and%d is a placeholder for a numeric type
#占位符%s %d# a= "My name is%s, age%d, is a%s"% ("Alex", "$", "SB") # print (a) # Name=input (">>>;") # Age=int (Input (">>>:") # Ll=input (">>>:") # # a= "My name is%s, age%d,%s"% (NAME,AGE,LL) # print (a)
Two-coding and binary
Encoding means the language of a computer, which is equivalent to a password. Coding is a bunch of binary numbers with 0 and 1.
The first invention of the computer was the United States, so the code was generated by the United States, called ASCII code.
The ASCII code is a 8 bit bit display of a font. That is, 8 binary digits display a font. Since the ASCII code is limited to the use of a small number of people, then produced a Uniocode (universal code). The first universal code was a font with 16 binary digits, but because the world had too many languages, it was raised to 32 binary digits for a font. However, because the number of language fonts has not reached the maximum, so Uniocode occupies a large space, but also wasted space. However, Uniocode can only be used in memory, not on the hard disk, or in transit. Later, according to Uniocode, the optimized version of the format was created, called Utf-8.
Utf-8 is a universal format for the world, and he is Uniocode's optimized version. He will save the data according to the bytes of each word, so it will not waste space. Our Chinese occupies 24 bits in the UTF-8 format.
But we in China have created a format of our China based on Uniocode, called GBK, which accounts for 16 bits. Corresponding to other countries will also have a corresponding format.
Level of unit: 1-bit--->bit
1 bytes Bytes 1bytes=8bit
1000 bytes 1kb 1kb=1024bytes
1 trillion 1MB 1mb=1024kb
1G 1GB 1GB=1MB
1T 1T=1024GB
Three-operator supplement
In Python2 and Python3, the/division sign results are not the same. Division sign is only rounded in Python2, but other methods can be used to remove the exact quotient. (from __future__ Import Division) is to add this piece of code.
And in the Python3 division sign is to take out the precise quotient. Equivalent to the From __FUTURE__ Import division in Python2.
Calculate symbol Additions
Division sign rounding out the second party
Compare symbol Additions
! = Not equal to <> is not equal to the recommended first type.
Assignment Operation symbols
+ = addition assignment operator a+=c equivalent to a=a+c-= subtraction assignment operator a-=c equivalent to a=a-c *= multiplication assignment operator a*=c equivalent to the a=a*c/= division assignment operator A/=c equivalent to the a=a/c%= the remainder assignment operator a%=c equivalent to a=a% **= the secondary assignment operator A**=c equivalent to a=a**c//= divisible assignment Operator A//=c equivalent to a=a//c
logical operators
and the right and left to the correct example: 3>4 and 3==3 condition is set to return true, not set to return false or or left or right one example: 3>4 or 3==3 The condition is set to return True, does not set the return false not to the right or wrong case: 3>4 not 3==3 condition returns True, does not set return False
In and not in
In the decision is or in the
Instead of in and in
Value = input (' Be careful to enter content: ') if "XI" in Value or "Lao Jiang" in Value: print (' Lad, don't wave ... ') value = input (' Please input carefully: ') if "Xi big" In Value:print (' lad, don't wave ..., re-enter ') elif "Lao Jiang" in Value:print (' small game, don't wave, re-enter ') else:print (value)
Retake Course day2 (Python Foundation 2)