#Python撲克牌的4種花色,撲克牌洗牌_2
import random
a1=[];a2=[];b1=[];b2=[];c1=[];c2=[];d1=[];d2=[]
card=random.sample(range(1,53),52)
for i in range(52):
if card[i]//13==1:f=”?心” #從word複製花色的圖形進去
elif card[i]//13==2:f=”?鑽”
elif card[i]//13==3:f=”?鏟”
else :f=”?花”
if card[i]%13== 0:p=”A”
elif card[i]%13==10:p=”J”
elif card[i]%13==11:p=”Q”
elif card[i]%13==12:p=”K”
else :p=str(card[i]%13+1) # %求餘數
if i%4 ==0:
a1.append(f)
a2.append(p)
if i%4 ==1:
b1.append(f)
b2.append(p)
if i%4 ==2:
c1.append(f)
c2.append(p)
if i%4 ==3:
d1.append(f)
d2.append(p)
print(“=一=*=二=*=三=*=四=”)
for j in range(13):
print(“%s%-2s “%(str(a1[j]),str(a2[j])),end=”*”)
print(“%s%-2s “%(str(b1[j]),str(b2[j])),end=”*”)
print(“%s%-2s “%(str(c1[j]),str(c2[j])),end=”*”)
print(“%s%-2s “%(str(d1[j]),str(d2[j])))


輸出結果:


![Python TQC 510 費氏數列,list[], f.append(n3) Python TQC 510 費氏數列,list[], f.append(n3)](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2022/04/20220522152013_66.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)




![Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index) Python: pandas.DataFrame (df) 的取值: df [單一字串] 或df [list_of_strings] 選取一個或多個columns; df [切片] 或 df [bool_Series] 選取多個rows #bool_Series長度同rows, index也需要同df.index ,可以使用.equals() 確認: df.index.equals(mask.index)](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250420212553_0_6fb2c3.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言