Django
官网案例
https://docs.djangoproject.com/zh-hans/4.2/intro/
投票程序
自定义一个投票问题:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| import sqlite3 import pandas as pd
conn = sqlite3.connect("db.sqlite3") cursor = conn.cursor()
cursor.execute('select * from polls_choice')
students = pd.read_excel("20-3.xlsx")
students_list = [] for stu in students["姓名"]: record = (stu, 0, 2) students_list.append(record)
cursor.executemany('insert into polls_choice(choice_text,votes,question_id) values (?,?,?)', students_list)
cursor.close()
conn.commit()
|