40923227 cp2020

  • Home
    • Site Map
    • reveal
    • blog
  • About
    • Develop
      • test
  • HomeWork
    • HW1
      • Overview
      • AGP Slots (AGP插槽)
      • Processors(處理器)
      • Video Displays and Video Cards(顯示器與顯示卡)
      • Video Output
      • Install and Configure Expansion Cards(安裝和配置擴充卡)
      • Storage Devices Overview(存儲設備概述)
      • Storage Devices Hard Disk Drives(儲存設備 硬碟驅動器)
      • Storage Devices  Hot Swapping(儲存設備 熱交換)
      • Heat Sources(熱源)
      • heat reduction
      • BIOS Settings(bios設置)
    • HW2
      • 作業2-1
      • 變數 Variables
      • HTML Tutorial HTML教程
    • HW3
      • Check Tic Tac Toe
      • Max Of Three
      • Tic Tac Toe Game
HW2 << Previous Next >> 變數 Variables

作業2-1

參考40923211 方法一 :
  • import urllib.request
    #導入urllib.request
    target_url = "https://nfulist.herokuapp.com/?semester=1091&courseno=0776"
    #設target_url = "網址"
    cp1b = []
    #設cp1b=數列
    for line in urllib.request.urlopen(target_url):
    #重複打開target_url的迴圈定義line
        cp1b.append(int(line.decode('utf-8').rstrip()))
        #把line重新編碼加進cp1b(數列)   註:rstrip()刪除字尾符號
    print(cp1b)
    
  • from random import shuffle #導入隨機洗牌
    list  = [40523138,40523148,40723217,40728238,40823148,40823152,40923201,40923202,40923203,40923204,40923205,
    40923206,40923207,40923208,40923209,40923210,40923211,40923212,40923213,40923214,40923216,40923217,40923218,
    40923219,40923220,40923221,40923223,40923224,40923225,40923226,40923227,40923228,40923229,40923230,40923231,
    40923232,40923233,40923234,40923235,40923236,40923237,40923238,40923239,40923240,40923241,40923242,40923243,
    40923244,40923245,40923246,40923247,40923248,40923249,40923250,40923251,40923252,40923253] 
    #列表[]
    shuffle(list) #shuffle=洗牌
    n=5
    m = int(len(list)/n) 
    list2 = [] 
    for i in range(0, len(list), m): #range()是一个函数, for i in range () 就是给i赋值: 
        list2.append(list[i:i+m]) 
    print(list2) 


  • HW2 << Previous Next >> 變數 Variables
  • Copyright © All rights reserved | This template is made with by Colorlib