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

Python notes - array

編輯:Python

'''a=[' Xiao Ming ',18,1]
print(a)

# One dimensional array new , Delete

list1 = [' Xiao Ming ',18,1.70]
list1.append(3)
del list1[1]
print(list1)'''

student=[' Xiao Ming ',' Xiaomei ',' Xiao Li ']
score={' Xiao Ming ':90,' Xiaomei ':95,' Xiao Li ':90}
#print(score)
#print(len(score))

# 2D array increment / Delete
score[' Xiao Ming ']=98
del score[' Xiao Ming ']
#print(score)
score[' Xiao Ming ']=100
#print(score)
student1=[' Xiao Ming ',' Xiao Li ',' Xiaomei ']
#print(student==student1) Judge
score1={' Xiao Ming ':90,' Xiao Li ':90,' Xiaomei ':95}
#print(score==score1)
students=[student,student1]
#print(students)
student2=[[' Xiao Ming ', ' Xiaomei ', ' Xiao Li '], [' Xiao Ming ', ' Xiao Li ', ' Xiaomei ']]
#print(student2[0][2])

# Three bit array ( Be clear about the top two )
score2={' The first group ':{' Xiao Ming ':90,' Xiao Li ':90,' Xiaomei ':95},
        ' The second group ':{' Xiao Ming ':90,' Xiaomei ':95,' Xiao Li ':90}
}
print(score2)
print(score2[' The first group '][' Xiao Ming '])
#print(score2[[1][' Xiao Ming '])
students = {
    ' The first group ':[' Xiao Ming ',' Xiaohong ',' Xiaogang ',' Xiaomei '],
    ' The second group ':[' cockroach ',' Xiaolan ',' Xiao Wei ',' Xiaofang ']
    }
print(students[' The first group '][3])
scores = [
    {' Xiao Ming ':95,' Xiaohong ':90,' Xiaogang ':100,' Xiaomei ':85},
    {' cockroach ':99,' Xiaolan ':89,' Xiao Wei ':93,' Xiaofang ':88}
    ]
print(scores[0][' Xiao Ming '])

# expand

# list [ Dictionaries {:}]
list1 = [{' jealousy ':'envy'},{' hate ':'hatred'},{' Love ':'love'}]
#print(list1[2][' Love '])
print(list1[2][' Love '])
# Please pass the knowledge you have learned , Put the dictionary dict1 Medium 'love' out , And print it out .
# Dictionaries {: list []}
dict1 = {1:['cake','scone','puff'],2:['London','Bristol','Bath'],3:['love','hatred','envy']}
print(dict1[3][0])

# Tuples (), Only the list that cannot be traversed can be read

# take tuple1 Medium A and list2 Medium D Print out .
tuple1 = ('A','B')
list2 = [('A','B'),('C','D'),('E','F')]
print(tuple1[0])
print(list2[1][1])

# list [ Dictionaries {: list }, Elements , list [ Dictionaries {:}]]

# Put... In the list “ The Wolf ” out , And print it out .
townee = [
    {' The kingdom of the sea ':[' Ariel The Little Mermaid '' King of the sea '' The little mermaid's grandmother '' Five sisters '],' The upper world ':[' prince ',' Neighboring Princess ']},
    ' ugly duckling ',' Firm tin soldier ',' Sleeping Beauty ',' The Frog Prince ',
    [{' Lead ':' Little red riding hood ',' Supporting rule 1':' grandmother ',' Supporting rule 2':' The hunter '},{' Villain ':' The Wolf '}]
    ]
print(townee[5][1][' Villain '])


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