3 <<
Previous Next >> 5
4
pj1-1亂數分組
Describe how to do an efficient random grouping for this course or do the roll calling randomly?
import random
List=[['40723104', '40723107', '40723114', '40723115', '40723118', '40723122', '40723123', '40723140', '40723149', '40723151', '40723153', '40723154', '40723155', '40623143', '40723108', '40723127', '40723132', '40723133', '40723137', '40723141', '40723143', '40723144', '40723147', '40723148', '40723150', '40723103', '40723110', '40723112', '40723120', '40723125', '40723126', '40723128', '40723130', '40723139', '40723142', '40723145', '40723146', '40423155', '40723101', '40723102', '40723106', '40723111', '40723119', '40723121', '40723124', '40723134', '40723135', '40723136', '40723138']]
#變數
List=List[0]
#將List數列隨機排列
random.shuffle(List)
#列印數列
print(List)
#數列(1~12)
print(List[0:12])
#數列(13~24)
print(List[12:24])
#數列(25~36)
print(List[24:36])
#數列(37~49)
print(List[36:49])
List=[['40723104', '40723107', '40723114', '40723115', '40723118', '40723122', '40723123', '40723140', '40723149', '40723151', '40723153', '40723154', '40723155', '40623143', '40723108', '40723127', '40723132', '40723133', '40723137', '40723141', '40723143', '40723144', '40723147', '40723148', '40723150', '40723103', '40723110', '40723112', '40723120', '40723125', '40723126', '40723128', '40723130', '40723139', '40723142', '40723145', '40723146', '40423155', '40723101', '40723102', '40723106', '40723111', '40723119', '40723121', '40723124', '40723134', '40723135', '40723136', '40723138']]
清單
List=List[0]
變數
random.shuffle(List)
使用random.shuffle隨機排列
print(List)
數列複印
print(List[a:b])
複印a-b
使用爬蟲程式來擷取網頁中的內容
網站https://buzzorange.com/techorange/2017/08/04/python-scraping/
來源https://nkust.gitbook.io/python/untitled
3 <<
Previous Next >> 5