#Python 3.X 程式語言特訓教材 6-42頁
import random
def lotto():
lottoLst=[]
cnt=0
while cnt <6 :
lottoNum = random.randint(1,49)
if lottoNum not in lottoLst:
lottoLst.append(lottoNum)
cnt += 1
lottoLst.sort()
print(lottoLst)
def main():
for i in range(1,6): #i=1,2,3,4,5
lotto()
main()

#綜合範例14
import random
randLst=[]
for i in range(100):
randNum = random.randint(1,1000)
randLst.append(randNum)
#print(randLst)
randLst.sort()
for j in range(1,101):
if j%10 == 0: print(“%4d” %randLst[j-1])
else:print(“%4d” %randLst[j-1],end=””)
print()
print(randLst[1])
print(randLst[-2])

#6-47:









]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' title='Python正則替換:全面掌握 re.sub 與 re.subn 的差異與實戰 #substitute(替換); . 預設匹配「除\n以外的任意單一字元」; pattern = re.compile(r'<w:p[^>]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' loading='lazy' width=350 height=233 />
近期留言