程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Eye of depth (I) -- some induction of Python knowledge points

編輯:Python

List of articles

  • Combination type
    • 1. list
    • 2. Tuples
    • 3. Dictionaries
    • 4. aggregate
  • Reserved words

Combination type

1. list

list Sequence type : Data has positional order
Representation :[data1,data2,…]

a = [1,2,3,4,5]
a[0]

2. Tuples

Representation : (data1,data2,…)
Element does not support modification

b = {
1,2,3,4}
b[0]

3. Dictionaries

Mapping type : adopt “ key ”-“ value ” Data storage and search are realized by mapping
Representation :{key1:value1,key2:value2,…}

students = {
202001:" Xiao Ming ",202002:" Xiaohong ",202003:" The small white "}
students[202001]

4. aggregate

A set of unequal elements , A disorderly
Representation :{data1,data2,…}

Reserved words

Hump body : Class name (AgeOfStudent)
Underline : Variable name and function name

Constant , All letters are capitalized

Incremental assignment
x += 10

Package assignment
x,y = 1,2
print(x,y)
x,y = y,x
print(x,y)

Control process
Sequential process
Circulation process
form :for Elements in Iteratable object
Execute statement

Execution process
From iteratable objects , Remove each element at once , And carry out the corresponding operation

res = 0
for i in [1,2,3,4]
res += i
res

while Judge the condition

i = 1
res = 0
while i <= 5:
res += i
i += 1
res

Line break

print(123,end=" ")
print(456)

PI = 1
X = 5
print("PI - ",PI,"X = ",E)

format
1.
print(“PI = {0}, E = {0}”,format(PI,E))

2. Fill output
print(“{0:_^20}”,format(PI))
3. Digit thousands separator

4. Simplified output of floating point numbers



Use spaces


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved