日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python新闻管理系统_python项目——新闻管理系统

發布時間:2025/3/15 python 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python新闻管理系统_python项目——新闻管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

fromcolorama import Fore,Stylefromgetpass import getpass #獲取用輸入密碼fromservice.user_service import UserServicefromservice.news_service import NewsServicefromservice.role_service import RoleService

import os #為了清空控制臺內容

import sys

import time

__user_service=UserService()

__news_service=NewsService()

__role_service=RoleService()whileTrue:

os.system("cls")

print(Fore.LIGHTBLUE_EX,"\n\t+++++++++++++++++++")

print(Fore.LIGHTBLUE_EX,"\n\t歡迎使用新聞管理系統")

print(Fore.LIGHTBLUE_EX,"\n\t+++++++++++++++++++")

print(Fore.LIGHTGREEN_EX,"\n\t1)登陸系統")

print(Fore.LIGHTGREEN_EX,"\n\t2)退出系統")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "1":

username= input("\n\t輸入你的用戶名:")

password= getpass("\n\t輸入你的密碼:")

result=__user_service.login(username,password)

#登陸成功if result ==True:

#查詢角色

role=__user_service.search_user_role(username)whileTrue:

os.system("cls")if role == "新聞編輯":

print("test")

elif role== "管理員":

print(Fore.LIGHTGREEN_EX,"\n\t1)新聞管理")

print(Fore.LIGHTGREEN_EX,"\n\t2)用戶管理")

print(Fore.LIGHTRED_EX,"\n\tback)退出登陸")

print(Fore.LIGHTRED_EX,"\n\texit)退出系統")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "1":whileTrue:

os.system("cls")

print(Fore.LIGHTGREEN_EX,"\n\t1)審批新聞")

print(Fore.LIGHTGREEN_EX,"\n\t2)刪除新聞")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "1":

page= 1

whileTrue:

os.system("cls")

count_page=__news_service.search_unreview_count_page()

result=__news_service.search_unreview_list(page)for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}\t{1}\t{2}\t{3}".format(index+1,one[1],one[2],one[3]))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTBLUE_EX,"\n\t{0}/{1}".format(page,count_page))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Fore.LIGHTRED_EX,"\n\tprev)上一頁")

print(Fore.LIGHTRED_EX,"\n\tnext)下一頁")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "back":breakelif opt== "prev" and page > 1:

page-=1elif opt== "next" and page

page+=1elifint(opt) >= 1 and int(opt) <= 10:

news_id= result[int(opt) - 1][0]

__news_service.update_unreview_news(news_id)

elif opt== "2":

page= 1

whileTrue:

os.system("cls")

count_page=__news_service.search_count_page()

result=__news_service.search_list(page)for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}\t{1}\t{2}\t{3}".format(index + 1, one[1], one[2], one[3]))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTBLUE_EX,"\n\t{0}/{1}".format(page, count_page))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Fore.LIGHTRED_EX,"\n\tprev)上一頁")

print(Fore.LIGHTRED_EX,"\n\tnext)下一頁")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "back":breakelif opt== "prev" and page > 1:

page-= 1elif opt== "next" and page

page+= 1elifint(opt) >= 1 and int(opt) <= 10:

news_id= result[int(opt) - 1][0]

__news_service.delete_by_id(news_id)

elif opt== "back":breakelif opt== "2":whileTrue:

os.system("cls")

print(Fore.LIGHTGREEN_EX,"\n\t1)添加用戶")

print(Fore.LIGHTGREEN_EX,"\n\t2)修改用戶")

print(Fore.LIGHTGREEN_EX,"\n\t3)刪除用戶")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "back":breakelif opt== "1":

os.system("cls")

username= input("\n\t你要添加的用戶名字")

password= getpass("\n\t輸入新用戶密碼")

repassword= getpass("\n\t再次輸入新用戶密碼")if password !=repassword:

print(Fore.LIGHTRED_EX,"\n\t兩次密碼不一致(3秒自動返回)")

time.sleep(3)continueemail= input("\n\t新用戶郵箱:")

result=__role_service.search_list()for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}.{1}".format(index+1,one[1]))

print(Style.RESET_ALL)

opt= input("\n\t新用戶的角色編號:")

role_id= result[int(opt)-1][0]

__user_service.insert_user(username,password,email,role_id)

print("\n\t保存成功(3秒自動返回)")

time.sleep(3)

elif opt== "2":

page= 1

whileTrue:

os.system("cls")

count_page=__user_service.search_count_page()

result=__user_service.search_list(page)for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}\t{1}\t{2}".format(index + 1, one[1], one[2]))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTBLUE_EX,"\n\t{0}/{1}".format(page, count_page))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Fore.LIGHTRED_EX,"\n\tprev)上一頁")

print(Fore.LIGHTRED_EX,"\n\tnext)下一頁")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "back":breakelif opt== "prev" and page > 1:

page-= 1elif opt== "next" and page

page+= 1elifint(opt) >= 1 and int(opt) <= 10:

os.system("cls")

user_id= result[int(opt)-1][0]

username= input("\n\t你要修改成的用戶名字")

password= getpass("\n\t輸入新密碼")

repassword= getpass("\n\t再次輸入新密碼")if password !=repassword:

print(Fore.LIGHTRED_EX,"\n\t兩次密碼不一致(3秒自動返回)")

time.sleep(3)

print(Style.RESET_ALL)breakemail= input("\n\t新用戶郵箱:")

result=__role_service.search_list()for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}.{1}".format(index + 1, one[1]))

print(Style.RESET_ALL)

opt= input("\n\t新用戶的角色編號:")

role_id= result[int(opt) - 1][0]

opt= input("\n\t是否保存(Y/N)")if opt.upper() == "Y":

__user_service.update(user_id,username,password,email,role_id)

print("\n\t保存成功(3秒自動返回)")

time.sleep(3)

elif opt== "3":

page= 1

whileTrue:

os.system("cls")

count_page=__user_service.search_count_page()

result=__user_service.search_list(page)for index inrange(len(result)):

one=result[index]

print(Fore.LIGHTBLUE_EX,"\n\t{0}\t{1}\t{2}".format(index + 1, one[1], one[2]))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTBLUE_EX,"\n\t{0}/{1}".format(page, count_page))

print(Fore.LIGHTBLUE_EX,"\n\t-------------------")

print(Fore.LIGHTRED_EX,"\n\tback)返回")

print(Fore.LIGHTRED_EX,"\n\tprev)上一頁")

print(Fore.LIGHTRED_EX,"\n\tnext)下一頁")

print(Style.RESET_ALL)

opt= input("\n\t輸入你的操作編號:")if opt == "back":breakelif opt== "prev" and page > 1:

page-= 1elif opt== "next" and page

page+= 1elifint(opt) >= 1 and int(opt) <= 10:

os.system("cls")

user_id= result[int(opt) - 1][0]

__user_service.delete_by_id(user_id)

print("\n\t刪除成功(3秒自動返回)")

time.sleep(3)

elif opt== "back":breakelif opt== "exit":

sys.exit(0)else:

print("\n\t登陸失敗,3秒自動返回")

time.sleep(3)

elif opt== "2":

sys.exit(0)#0代表安全退出,等數據釋放等

總結

以上是生活随笔為你收集整理的python新闻管理系统_python项目——新闻管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。