40823108 wcm2020

  • Home
    • Site Map
    • reveal
    • blog
  • 簡介
  • Grouping
    • 1a
  • 每周進度
    • W10-W11
    • W12-W15
    • W16-W17
  • Python程式
  • Cmsimde建立網誌方法
  • SSH教學
    • SSH Key產生
    • SSH Putty設定
  • Pelican建立Blog
  • @gm帳號建立blogger
  • VirtualBOX虛擬主機
  • scite編譯器
  • 期末報告
W16-W17 << Previous Next >> Cmsimde建立網誌方法

Python程式

import csv
   
# read student list
filename = 'D:/1a/1alist.txt'
with open(filename, encoding="utf-8") as f:
    content = f.readlines()
    student = [x.strip() for x in content]
#print(content)
#print(student)
   
# Timestamp, email, ????, url, score, desp, memo
# 0, 1, 2, 3, 4, 5, 6
#total = 0
  
all = {}
with open('D:/1a/1a.csv', encoding="utf-8") as csv_file:
    csv_reader = csv.reader(csv_file, delimiter=',')
       
    line_count = 0
    for row in csv_reader:
        if line_count == 0:
            #print(f'Column names are {", ".join(row)}')
            line_count += 1
        else:
            student_num = row[1].split("@")[0]
            #print(student_num)
            student_score = row[4]
            #print(student_score)
            try:
                all.update({student_num: student_score})
            except:
                all.update({student_num: "error"})
            #print(f'\t{row[0]} works in the {row[1]} department, and was born in {row[2]}.')
            #print(f'\t{row[4]}')
            #total += int(row[4])
            line_count += 1
#print(all)
#print(student)
  
for i in student:
       
    #if i in all:
        #pass
    #else:
        #print(str(i))
       
    try:
        print(i + "\t" + all[i])
    except:
        print(i + "\t60")
  
   
    #print(f'Processed {line_count} lines.')
    #print("??=" + str(total/line_count))

Flask程式:

from flask import Flask
   
app = Flask(__name__)
   
@app.route('/') 
def hello_world():
    return 'Hello, From Flask!'
   
if __name__== '__main__': 
    app.run()

W16-W17 << Previous Next >> Cmsimde建立網誌方法

Copyright © All rights reserved | This template is made with by Colorlib