1. 程式人生 > 遊戲 >音階至上 律動我心!《R2Beat: 音速覺醒》正式上架Steam!

音階至上 律動我心!《R2Beat: 音速覺醒》正式上架Steam!

列表

獲取複雜資料結構裡面的元素資訊


'''
# list1=[[1,2,3],['a','b','c']]
# print(list1[0][2])
# print(list1[1][2])

 




list3=[[1,2,3],['a','b','c',["Go",["Python"]]]]

# print(list3[1][3][0])
#
# print(list3[1][3][1][0])

 




list1=[[1,2,3],['a','b','c']]

list3=[[1,2,3],['a','b','c',["Go",["Python"]]]]
list9=[1,2,3,4,5,6,7,8,9]
# print(len(list3))
# print(len(list1))
# print(len(list9))

 

 




list1=["Go","Python","Java","Net","PHP"]
# #只輸出列表中的前兩位
# print(list1[0:2])
# print(list1[0:4])


 

 

 






list1=["Go","Python","Java","Net","PHP"]

# 輸出python到php

print(list1[1:5])
# print(list1[1:])


 




# 輸出最後一位
print(list1[-1])
for list7 in list1:
print(list7)

 

 

 

今日練習

 

while True:
money=int(input('請輸入價錢\n'))
if money<60:
print('便宜')
elif money>=60 and money<100:
print('中等')
elif money==100:
print('貴')
else:
print('價格到位')
break

 

while True:
mima=int(input('請輸入密碼\n'))
if mima!=986435233:
print('密碼錯誤')
elif mima == 986435233:
print('密碼正確')
break

 

while True:
Verification=int(input('請輸入驗證碼\n'))
if Verification!=1314:
print('驗證碼錯誤')
elif Verification==1314:
print('驗證碼正確')
break


 

 




while True:
name=str (input('請輸入名字\n'))
if name!='段舒元':
print('名字錯誤')
elif name=='段舒元':
print('名字正確')
break

 




while True:
shu=float(input('請輸入薪資\n'))
if shu!=1314.66:
print('薪資錯誤')
elif shu==1314.66:
print('薪資正確')
break

 

 

練習字串

 

name='   duan shu yuan   '
print(name.upper())
print(name.upper().islower())
print(name.lower())
print(name.lower().isupper())
print(name.startswith('d'))
print(name.endswith('n'))
print(name.find('8'))
print(len(name))
print(name.index('u'))
print(name.replace('duan','yuan'))
print(name.strip())
for name1 in name:
print(name1)
print(name.split(' '))
name2=' '.join(name.split(' '))
print(name2)

 

 

 

phone='  xiao  mi   '
print(phone.upper())
print(phone.isupper())
print(phone.lower())
print(phone.lower().islower())
print(phone.startswith(' '))
print(phone.endswith(' '))
print(len(phone))
print(phone.find('o'))
print(phone.index(' '))
print(phone.replace(' ','xiao'))
print(phone.strip())
for phone1 in phone:
print(phone1)
print(phone.split('xiao'))
phone2='xiao'.join(phone.split('xiao'))
print(phone2)

 

book='Python'
print(book.upper())
print(book.islower())
print(book.lower().islower())
print(book.startswith('b'))
print(book.endswith('k'))
print(book.find('p'))
print(len(book))
print(book.index('t'))
print(book.replace('P','p'))
print(book.strip())
for book1 in book:
print(book1)
print(book.split('y'))
book2=','.join(book.split('t'))
print(book2)

 

clothes=' adidas'
print(clothes.upper().isupper())
print(clothes.lower().islower())
print(clothes.startswith(' '))
print(clothes.endswith('s'))
print(len(clothes))
print(clothes.find('i'))
print(clothes.strip())
print(clothes.index('d'))
print(clothes.replace('d','D'))
for clothes1 in clothes:
print(clothes1)
print(clothes.split('i'))
clothes2=','.join(clothes.split('i'))
print(clothes2)


 


dog='er ha'
print(dog.upper().islower())
print(dog.lower().isupper())
print(dog.startswith('e'))
print(dog.endswith('a'))
print(dog.find('h'))
print(len(dog))
print(dog.index('a'))
print(dog.strip())
print(dog.replace('e','E'))
for dog1 in dog:
print(dog1)
print(dog.split(' '))
dog2=','.join(dog.split(' '))
print(dog2)


 



app='pycharm'
print(app.upper())
print(app.lower())
print(app.islower())
print(app.isupper())
print(app.startswith('p'))
print(app.endswith('m'))
print(len(app))
print(app.strip())
print(app.replace('p','P'))
print(app.split('c'))
app1=','.join(app.split('c'))
print(app1)
for app2 in app:
print(app2)




 

練習列表


加減
hao=[5,7,9,3,8,15,0,'r','y']
hao.append(5)
hao.insert(4,20)
hao.remove('r')
hao.remove('y')
print(hao)
print(hao.pop())

# 複製 檢視 修改 檢視索引 檢視元素的個數 清空
hao1=hao.copy()
print(hao1)
print(hao1[5])
hao1[2]=1314
print(hao1)
print(hao1.index(8))
print(hao1.count(5))
hao1.clear()
print(hao1)
hao.extend(hao1)
print(hao)
hao.reverse()
print(hao)
hao.sort(reverse=True)
print(hao)
hao.sort()
print(hao)
hao3=[[1,2,3,4],['e','r','p',['h','g',['t','y']]]]
print(hao3[1][3][2][1])
hao4=[[1,2,3],[4,5,6],[7,8,9]]
print(hao4[2][1])
hao5=[1,2,3,[5,3,6,8,[5,6,8,9,7]]]
print(hao5[3][4][3])
print(len(hao3))
print(len(hao4))
print(len(hao5))
print(hao[0:2])
print(hao[3:6])
print(hao[2:])
print(hao[-1])