Learn Python sixth day

Today who had become dead to learn Python !!!!

For this reason also I bought a small series of your favorite McPython!

Childhood teacher said interest is the best teacher, so it is to buy this book to improve their interest in learning the game through my world! ! !

Of course, there are selfish it ....

# ! / Usr / bin / Python the env 
# - * - Coding: UTF8 - * - 
# Boolean value 
V == =. 1. 1 Print (V) 
A ! = 2. 1 =
 Print (A)
 "" " 
calculated first brackets * *** 
True OR ==> True 
True the AND ==> continue to move 
False OR ==> continue to move 
False the AND ==> False "" " 
User = " Alex " 
pwd = " 123 " 
V = User == ' Alex ' and (pwd == " 123 "or 1 == 1) and pwd == "

  1234 " 
Print (V)
 # arithmetic assignment operator = 
COUNT = 0 
Number = 0 
COUNT = COUNT +. 1 
Number + =. 1
 Print (COUNT == Number)
 # The result is the actual value 
# arithmetical operation 
A = 10 * 10 Print (A )
 # assignment operator 
B = 0 
B = B +. 1 
B   +. 1 =
 Print (B)
 # result Boolean 
# comparison operation 
C =. 1>. 5 
C Print (C)
 # logical operation 
D =. 1>. 6 or . 1 == 1


Print (D)
 # membership operator 
E = " ah "  in  " Ah Kun " 
Print (E)
 # basic data types 
# number 
NUM = 123 
V = num.bit_length ()
 Print (V)
 # String 
name = " csdnak " 
V1 = name.upper ()
 Print (v1)
 "" " 
plastic int 
A Python 3 years, 31415926159261592615 ... (unlimited) 
Python 2, the 1234567890 (scoped) 
a long long 
Python 2 years, 31415926159261592615 ... 
" "" 

# digital magic in int where, ctrl + left mouse button click int
404 = A 
B = a.bit_length ()
 Print (B)
 # type () magic mirror, you can view the relevant type 
C = " 123 " 
Print (type (C), C) 
D = int (C) 
D = 321 + D
 Print (type (D), D)
 # hexadecimal binary conversion, 8, 16, etc. 
NUM = " a " 
V = int (NUM, Base = 16 )
 Print (V)
 # current number represented by n-bit binary at least 
age 10 = 
R & lt = age.bit_length ()
 Print (R & lt)
 # string str Lane, ctrl + left mouse button click str. 
S1 = " csdnak" 
A = s1.upper () 
B = s1.title () 
C = s1.startswith ( ' CS ' )
 Print (A, B, C)
 # initials 
V = s1.capitalize ()
 Print (V)
 # All change lowercase, casefold more Niubi, many unknown object strain lowercase 
v1 = s1.casefold ()
 Print (v1)
 # Like casefold function, but only the regular characters to lower case 
v2 = s1.lower ()
 Print (v2)
 # 20 represents the total length and the character is centered 
# * number optional fill symbols may also be any other character, but only a 
V3 = s1.center (20, " * " )
 Print(V3)
 # contains several s1 in the c 
# 2 as a starting position, ending position 5, both dispensable 
V4 = s1.count ( ' c ' , 2,5 )
 Print (V4)
 # what What end 
# to start what return bool Boolean value 
V5 = s1.endswith ( ' dn ' ) 
V6 = s1.startswith ( ' c ' )
 Print (V5, V6)
 # from looking back, found after the first one, obtaining position 
# > or> =, support section (Example: 9 or greater than 12) can not be found is outputted -1 
Test = " csdngithubak " 
V7 = test.find ( ' BAK ' , 9,12 )
Print (V7)
 # format, a string will replace the placeholder specified value 
# if the object is the number from left to right in order to replace (the first bit is 0) 
T = ' I AM {name }, Age {NUM} \ n- ' 
T1 = ' I AM {0}, Age {}. 1 \ n- ' 
V8 = t.format (name = ' WXK ' , NUM =. 19 ) 
V9 = t1.format ( ' WXK ' 19 )
 # dictionary-based format, the incoming values { "name": 'WXK', "NUM": 19} 
V10 = t.format_map ({ " name " : ' WXK ' , " NUM " :19})
print(V8, V9, V10)
 # index will not find the error, it is generally used Find 
V11 = test.index ( ' . 8 ' )
 Print (V11)
 # string contains only letters or numbers, if not return False 
# can also be pure numbers and letters 
T2 = " csdnak187 " 
V12 = t2.isalnum ()
 Print (V12) 


"" " 
# list in the list, ctrl + left mouse button click on the list. 
... 
# Ganso tuple in, ctrl + left mouse click on key tuple. 
... 
# dictionary dict years, ctrl + left mouse button click dict. 
... 
# Boolean value bool years, ctrl + left mouse button click bool. 
... 
"" "

 

Guess you like

Origin www.cnblogs.com/tomcache/p/11441126.html