本程序借助pycharm平台设计,主要功能是实现错题标记入库和重新回顾,界面分为两大板块各自对应七大类题目,错题入库板块主要是通过提取题目照片和输入难度作为标记,将题目和答案的照片存入对应的文件夹内,并将地址信息存入MYSQL数据库中;题目回顾则是从题库中根据标记随即选择四道难度不同的题目,并通过对比答案后判断对错实现对题目难度标记的增减,达到题目复习的效果
以下为部分代码:(仅供参考)
def add_higher_mathematics_grade(self):
import mysql.connector
global questions_grade
global questions_name
questions_grade = str(questions_grade).replace('[', '').replace(']', '').replace("'", "")
questions_grade = int(questions_grade)
print(questions_grade)
print(questions_name)
questions_grade = questions_grade + 1
questions_grade = str(questions_grade)
questions_name = str(questions_name)
renew_question = mysql.connector.connect(
host="localhost",
user="root",
passwd="dxy123",
db='study'
)
mycursor = renew_question.cursor()
mysql= 'update 高数 set 标记=%s where 题目编号=%s'
information=(questions_grade,questions_name)
mycursor.execute(mysql,information)
renew_question.commit()
renew_question.close()
def reduce_higher_mathematics_grade(self):
import mysql.connector
global questions_grade
global questions_name
questions_grade = str(questions_grade).replace('[', '').replace(']', '').replace("'", "")
questions_grade=int(questions_grade)
print(questions_grade)
print(questions_name)
questions_grade = questions_grade - 1
questions_grade=str(questions_grade)
questions_name = str(questions_name)
if questions_grade==0:
renew_question = mysql.connector.connect(
host="localhost",
user="root",
passwd="dxy123",
db='study'
)
mycursor = renew_question.cursor()
mysql = "delete from 高数 where 题目编号=%s"
mycursor.execute(mysql,(questions_name,))
renew_question.commit()
renew_question.close()
else:
renew_question = mysql.connector.connect(
host="localhost",
user="root",
passwd="dxy123",
db='study'
)
mycursor = renew_question.cursor()
mysql = 'update 高数 set 标记=%s where 题目编号=%s'
mycursor.execute(mysql,(questions_grade,questions_name,))
renew_question.commit()
renew_question.close()
def review_higher_mathematics_page(self):
import mysql.connector
import random
global easy_question_list
global difficult_question_list
global problem_question_list
global max_global
global first_global
global second_global
import numpy as np
global random_easy_number1
global random_easy_number2
global random_difficult_number1
global random_problem_number1
self.review_page.destroy()
self.page2 = Frame(self.root)
self.page2.pack()
Label(self.page2, text='杜晓扬考研错题本').grid(row=0, stick=W, pady=30)
select_question = mysql.connector.connect(
host="localhost",
user="root",
passwd="dxy123",
db='study'
)
mycursor1 = select_question.cursor()
mysql1= 'SELECT * FROM 高数 WHERE 标记 <= 2'
mycursor1.execute(mysql1)
# 获取查询结果并赋值给变量
easy_question_list = mycursor1.fetchall()
for i in easy_question_list:
print(i)
# 关闭游标和连接
mycursor1.close()
matrix1= np.array(easy_question_list)
easy_question_list_rows,easy_question_list_cols=matrix1.shape
print(easy_question_list_rows)
print(easy_question_list_cols)
mycursor2 = select_question.cursor()
mysql1 = 'SELECT * FROM 高数 WHERE 标记 > 2 and 标记 <= 4'
mycursor2.execute(mysql1)
# 获取查询结果并赋值给变量
difficult_question_list = mycursor2.fetchall()
for j in difficult_question_list:
print(j)
# 关闭游标和连接
mycursor2.close()
matrix2 = np.array(difficult_question_list)
difficult_question_list_rows, difficult_question_list_cols = matrix2.shape
mycursor3 = select_question.cursor()
mysql1 = 'SELECT * FROM 高数 WHERE 标记 > 4 '
mycursor3.execute(mysql1)
# 获取查询结果并赋值给变量
problem_question_list = mycursor3.fetchall()
for k in problem_question_list:
print(k)
# 关闭游标和连接
mycursor3.close()
matrix3 = np.array(problem_question_list)
problem_question_list_rows, problem_question_list_cols = matrix3.shape
select_question.close()
#选题
first_num = 1
random_easy_number1 = random.randint(first_num,easy_question_list_rows)
random_easy_number2 = random.randint(first_num, easy_question_list_rows)
while random_easy_number1 == random_easy_number2:
random_easy_number2 = random.randint(first_num, easy_question_list_rows)
random_difficult_number1 = random.randint(first_num, difficult_question_list_rows)
random_problem_number1 = random.randint(first_num, problem_question_list_rows)
Button(self.page2, text='出题', command=self.set_question).grid(row=1, pady=5)
Button(self.page2, text='1',command=self.question1).grid(row=2, pady=5)
Button(self.page2, text='2',command=self.question2).grid(row=3, pady=5)
Button(self.page2, text='3',command=self.question3).grid(row=4, pady=5)
Button(self.page2, text='4',command=self.question4).grid(row=5, pady=5)
Button(self.page2, text='答案',command=self.show_answer).grid(row=6, pady=5)
Button(self.page2, text='对',command=self.reduce_higher_mathematics_grade).grid(row=7, pady=5)
Button(self.page2, text='错',command=self.add_higher_mathematics_grade).grid(row=8, pady=5)