python基于时间序列分析的降雨量预测

本文介绍了如何在Python环境中使用pip安装相关库(如pyqt5,requests,sklearn,pymysql,tensorflow,pandas,keras),并详细步骤说明了如何创建数据库、执行SQL语句、配置数据库连接以及实现登录界面的功能,包括密码验证和数据库登录过程。
摘要由CSDN通过智能技术生成

项目运行

需要先安装Python的相关依赖:pyqt55.15.2,pyqt-sip12.9.1,requests,sklearn,pymysql,tensorflow1.14.0pandas,keras2.2.5使用pip install 安装

第一步:创建数据库

第二步:执行SQL语句,.sql文件,运行该文件中的SQL语句

第三步:修改源代码中的settings.py文件,改成自己的mysql数据库用户名和密码

第四步:运行命令:python manage.py runserver 8000

第五步:打开浏览器查看http://127.0.0.1:8000

毕设帮助,指导,本源码分享,调试部署(见文末)

系统介绍:

在这里插入图片描述

功能截图:

在这里插入图片描述
在这里插入图片描述

编程人员在搭建的开发环境中,会让各种编程技术一起呈现出最终效果。本节就展示关键部分的页面效果。

代码实现:

# -*- coding: utf-8 -*-


from PyQt5 import QtGui
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import *

from Ui_login import Ui_LoginDialog
from Ui_login import ClickedLabel

from mainwindow import MainWindow

import os
import sys
import json
import hashlib
import pymysql
from config import conn



class LoginDialog(QDialog, Ui_LoginDialog):
    def __init__(self, parent=None):
        super(LoginDialog, self).__init__(parent)
        self.setupUi(self)
        self.setStyleSheet(TextStyle)
        self.login_success = False
        self.initLoginInfo()
        self.focusPosition()

    def focusPosition(self):
        if not self.account_number.text():
            self.account_number.setFocus(True)
        elif not self.password.text():
            self.password.setFocus(True)
        else:
            self.verification_code.setFocus(True)

    def loadConfig(self):
        json_path = os.path.dirname(os.path.realpath(sys.argv[0])) + '\\login.json'
        if os.path.exists(json_path):
            with open(json_path, 'r') as f:
                self.login_info = json.load(f)
                return True
        else:
            self.login_info = {}
            return False

    def initLoginInfo(self):
        if self.loadConfig():
            if 'account_number' in self.login_info.keys():
                self.remember_account_number.setChecked(True)
                self.account_number.setText(self.login_info['account_number'])
            else:
                self.remember_account_number.setChecked(False)

            if 'password' in self.login_info.keys():
                self.remember_password.setChecked(True)
                self.password.setText(self.login_info['password'])
            else:
                self.remember_password.setChecked(False)

            if 'server_name' in self.login_info.keys():
                self.server_name.setText(self.login_info['server_name'])
            if 'database_name' in self.login_info.keys():
                self.database_name.setText(self.login_info['database_name'])
            if 'username' in self.login_info.keys():
                self.username.setText(self.login_info['username'])
            if 'database_password' in self.login_info.keys():
                self.database_password.setText(self.login_info['database_password'])

    @pyqtSlot()
    def on_confirm_clicked(self):
        # 清除焦点
        self.server_name.clearFocus()
        self.username.clearFocus()
        self.database_password.clearFocus()
        # 换页
        self.stackedWidget.setCurrentIndex(0)

    @pyqtSlot()
    def on_go_back_1_clicked(self):
        # 清除焦点
        self.server_name.clearFocus()
        self.username.clearFocus()
        self.database_password.clearFocus()
        # 换页
        self.stackedWidget.setCurrentIndex(0)

    '''连接SQL数据库'''

    def connectDB(self, server, database, uid, pwd):
        try:
            self.cursor = conn.cursor()

        except Exception as e:
            print('connectDB():\n' + repr(e))
            sys.exit(-1)

    def verifyPassword(self):
        self.cursor.execute('select * from User')

        self.row = self.cursor.fetchall()
        print(self.row)

    # self.row_sum = len(self.row)
    # if right:
    # return True
    # else:
    # return False

    @pyqtSlot()
    def on_login_clicked(self):
        # 用户登录
        account_number = self.account_number.text()
        if self.password.text():
            if len(self.password.text()) != 32:
                password = hashlib.md5(self.password.text().encode('utf-8')).hexdigest()
            else:
                password = self.password.text()
        else:
            password = ''
        # 数据库登录
        server_name = self.server_name.text()
        database_name = self.database_name.text()
        username = self.username.text()
        database_password = self.database_password.text()

        if self.login_info:
            if self.remember_account_number.isChecked():
                if account_number != self.login_info['account_number']:
                    self.login_info['account_number'] = account_number
            else:
                if 'account_number' in self.login_info.keys():
                    self.login_info['account_number'] = ''
            if self.remember_password.isChecked():
                if password != self.login_info['password']:
                    self.login_info['password'] = password
            else:
                if 'password' in self.login_info.keys():
                    self.login_info['password'] = ''
            if server_name != self.login_info['server_name']:
                self.login_info['server_name'] = server_name
            if database_name != self.login_info['database_name']:
                self.login_info['database_name'] = database_name
            if username != self.login_info['username']:
                self.login_info['username'] = username
            if database_password != self.login_info['database_password']:
                self.login_info['database_password'] = database_password
        else:
            self.login_info['account_number'] = account_number
            self.login_info['password'] = password
            self.login_info['server_name'] = server_name
            self.login_info['database_name'] = database_name
            self.login_info['username'] = username
            self.login_info['database_password'] = database_password

        print(self.login_info)
        json_path = os.path.dirname(os.path.realpath(sys.argv[0])) + '\\login.json'
        with open(json_path, 'w') as f:
            f.write(json.dumps(self.login_info))

        self.connectDB(server_name, database_name, username, database_password)
        # self.verifyPassword()
        correct_code = self.str_verification_code.lower()
        print(self.str_verification_code, correct_code)
        verification_code = self.verification_code.text().lower()
        if not verification_code:
            msg_box = QMessageBox()
            msg_box.setWindowTitle('提示')
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(":/mainwindow/images/mainwindow/money-bag.png"), QtGui.QIcon.Normal,
                           QtGui.QIcon.Off)
            msg_box.setWindowIcon(icon)
            msg_box.setIcon(QMessageBox.Information)
            msg_box.setText('验证码不能为空!')
            msg_box.addButton('我知道了', QMessageBox.AcceptRole)
            msg_box.exec()
            return
        else:
            if correct_code != verification_code:
                msg_box = QMessageBox()
                msg_box.setWindowTitle('错误')
                icon = QtGui.QIcon()
                icon.addPixmap(QtGui.QPixmap(":/mainwindow/images/mainwindow/money-bag.png"), QtGui.QIcon.Normal,
                               QtGui.QIcon.Off)
                msg_box.setWindowIcon(icon)
                msg_box.setIcon(QMessageBox.Critical)
                msg_box.setText('验证码错误!')
                msg_box.addButton('我知道了', QMessageBox.AcceptRole)
                msg_box.exec()
                return
            else:
                self.cursor.execute("select * from user")
                data = self.cursor.fetchall()
                for row in data:
                    print(row[1], row[8])
                    if row[1] == account_number and row[8] == password:
                        self.login_success = True
                        self.hide()
                        # self.parent().show()
                        self.mainwindow = MainWindow(self)
                        self.mainwindow.show()
                # else:
                #     msg_box = QMessageBox()
                #     msg_box.setWindowTitle('错误')
                #     icon = QtGui.QIcon()
                #     icon.addPixmap(QtGui.QPixmap(":/mainwindow/images/mainwindow/money-bag.png"), QtGui.QIcon.Normal,
                #                    QtGui.QIcon.Off)
                #     msg_box.setWindowIcon(icon)
                #     msg_box.setIcon(QMessageBox.Critical)
                #     msg_box.setText('账户密码不正确!!')
                #     msg_box.addButton('我知道了', QMessageBox.AcceptRole)
                #     msg_box.exec()

    @pyqtSlot()
    def on_go_back_2_clicked(self):
        self.stackedWidget.setCurrentIndex(0)

    @pyqtSlot()
    def on_remember_password_clicked(self):
        if not self.remember_account_number.isChecked():
            self.remember_account_number.setChecked(True)

    def closeEvent(self, event):
        reply = QMessageBox.question(self, '提示', '确认退出程序?', QMessageBox.Yes | QMessageBox.No)
        if reply == QMessageBox.Yes:
            event.accept()
            sys.exit()
        else:
            event.ignore()


TextStyle = """
	QMessageBox QPushButton[text="OK"] {
		qproperty-text: "好的";
	}
	QMessageBox QPushButton[text="Open"] {
		qproperty-text: "打开";
	}
	QMessageBox QPushButton[text="Save"] {
		qproperty-text: "保存";
	}
	QMessageBox QPushButton[text="Cancel"] {
		qproperty-text: "取消";
	}
	QMessageBox QPushButton[text="Close"] {
		qproperty-text: "关闭";
	}
	QMessageBox QPushButton[text="Discard"] {
		qproperty-text: "不保存";
	}
	QMessageBox QPushButton[text="Don't Save"] {
		qproperty-text: "不保存";
	}
	QMessageBox QPushButton[text="Apply"] {
		qproperty-text: "应用";
	}
	QMessageBox QPushButton[text="Reset"] {
		qproperty-text: "重置";
	}
	QMessageBox QPushButton[text="Restore Defaults"] {
		qproperty-text: "恢复默认";
	}
	QMessageBox QPushButton[text="Help"] {
		qproperty-text: "帮助";
	}
	QMessageBox QPushButton[text="Save All"] {
		qproperty-text: "保存全部";
	}
	QMessageBox QPushButton[text="&Yes"] {
		qproperty-text: "是";
	}
	QMessageBox QPushButton[text="Yes to &All"] {
		qproperty-text: "全部都是";
	}
	QMessageBox QPushButton[text="&No"] {
		qproperty-text: "不";
	}
	QMessageBox QPushButton[text="N&o to All"] {
		qproperty-text: "全部都不";
	}
	QMessageBox QPushButton[text="Abort"] {
		qproperty-text: "终止";
	}
	QMessageBox QPushButton[text="Retry"] {
		qproperty-text: "重试";
	}
	QMessageBox QPushButton[text="Ignore"] {
		qproperty-text: "忽略";
	}
	"""

if __name__ == "__main__":
    app = QApplication(sys.argv)
    login = LoginDialog()
    login.show()
    sys.exit(app.exec_())

总结:

本网站开发所采用的python等技术,这些技术是本人在大学期间非常熟悉和进行了深度钻研的技术,可以保证网站的正常开发,不会在中途因为技术问题出现错误。而且这两种技术应用非常的广泛,如果在开发网站的过程中遇到了啥问题,在网上也可以很快的找到答案。另外本系统在数据方面用的mysql数据库,mysql数据库是一个功能非常强大的数据库,语句非常的简单,数据存储和处理的能力非常的强。特别适合本网站。

源码获取:

大家点赞、收藏、关注、评论啦 、查看👇🏻获取联系方式👇🏻

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

paterWang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值