Python?? ??? ?? ?? ?? ???? ???? ??
May 12, 2023 am 09:43 AM1. ??? ??
1. ?? ?? ??
3. ?? ?? ??
5. ? ?? ? ??
7 .?? ?? ?? ??
0. ??? ??
2. ??? ?? ??
1. ?? ??: win7
2.Python ?? ??: os,re
3. ?? ??
import os filename='students.txt' def main(): while True: menum() choice=int(input('請選擇功能:')) if choice in [0,1,2,3,4,5,6,7]: if choice==0: answer=input('您確定要退出系統(tǒng)嗎?(y/n)') if answer=='y' or answer=='Y': print('感謝您的使用!') break #退出while循環(huán)并退出系統(tǒng) else: continue elif choice == 1: insert() #錄入學(xué)生信息 elif choice == 2: search() #查找學(xué)生信息 elif choice == 3: delete() #刪除學(xué)生信息 elif choice == 4: modify() #修改學(xué)生信息 elif choice == 5: sort() #成績排序 elif choice == 6: total() #統(tǒng)計學(xué)生總?cè)藬?shù) elif choice == 7: show() #顯示所有學(xué)生信息 def insert(): student_list=[] #用于存儲學(xué)生信息,列表每個元素是字典。 while True: id=input('請輸入學(xué)生ID:') if not id: break name=input('請輸入學(xué)生姓名:') if not name: break try: Englist=int(input('請輸入英語成績:')) Python=int(input('請輸入Python成績:')) Java=int(input('請輸入Java成績:')) except: print('輸入無效,不是整數(shù)類型,請重新輸入!') continue #將錄入的學(xué)生信息保存到字典中 student={'id':id,'name':name,'English':Englist,'Python':Python,'Java':Java} #將學(xué)生信息添加到列表中 student_list.append(student) answer=input('是否繼續(xù)添加?(y/n)') if answer=='y' or answer=='Y': continue else: break #將學(xué)生信息保存在文件中 save(student_list) print('學(xué)生信息錄入完畢!') pass def search(): student_query=[] #用列表存儲,防止有同名學(xué)生。 while True: id='' name='' if os.path.exists(filename): mode=input('按ID查找請輸入1,按姓名查找請輸入2:') if mode == '1': id=input('請輸入要查找的學(xué)生ID:') elif mode == '2': name=input('請輸入要查找的學(xué)生姓名:') else: print('您的輸入有誤,請重新輸入!') search() with open(filename,'r',encoding='utf-8') as rfile: student=rfile.readlines() for item in student: d=dict(eval(item)) if id!='': if d['id']==id: student_query.append(d) elif name!='': if d['name']==name: student_query.append(d) #顯示查詢結(jié)果 show_student(student_query) student_query.clear() #清空列表 answer=input('是否要繼續(xù)查詢?(y/n)') if answer=='y' or answer=='Y': continue else: break else: print('暫未保存學(xué)生信息。') return pass def delete(): while True: student_id=input('請輸入要刪除的學(xué)生ID:') if student_id != '': if os.path.exists(filename): #判斷文件是否存在 with open(filename,'r',encoding='utf-8') as file: student_old=file.readlines() #讀取所有學(xué)生信息并保存在列表中 else: student_old=[] flag=False #用于標(biāo)記是否刪除 if student_old: with open(filename,'w',encoding='utf-8') as wfile: d={} for item in student_old: #遍歷學(xué)生信息列表 d=dict(eval(item)) #將字符串轉(zhuǎn)成字典 if d['id']!=student_id: wfile.write(str(d)+'\n') else: flag=True if flag: print(f'id為{student_id}的學(xué)生信息已被刪除') else: print(f'沒有找到ID為{student_id}的學(xué)生信息') else: print('無此學(xué)生信息') break show() #刪完之后重新顯示所有學(xué)生信息 answer=input('是否繼續(xù)刪除?(y/n)') if answer=='y' or answer=='Y': continue else: break pass def modify(): show() if os.path.exists(filename): #判斷文件是否存在 with open(filename,'r',encoding='utf-8') as rfile: student_old=rfile.readlines() else: return #結(jié)束函數(shù) student_id=input('請輸入要修改信息的學(xué)生ID:') with open(filename,'w',encoding='utf-8') as wfile: for item in student_old: d=dict(eval(item)) if d['id']==student_id: print('找到此學(xué)生信息,可以修改。') while True: try: d['name']=input('請輸入學(xué)生姓名:') d['English']=input('請輸入English成績:') d['Python']=input('請輸入Python成績:') d['Java']=input('請輸入Java成績:') except: print('您的輸入有誤請重新輸入!') else: break wfile.write(str(d)+'\n') print('修改成功!') else: wfile.write(str(d)+'\n') answer=input('是否繼續(xù)修改其他學(xué)生信息?(y/n)') if answer=='y': modify() pass def sort(): show() if os.path.exists(filename): with open(filename,'r',encoding='utf-8') as rfile: student_list=rfile.readlines() student_new=[] for item in student_list: d=dict(eval(item)) student_new.append(d) else: return asc_or_desc=input('請選擇(0:升序,1:降序):') if asc_or_desc=='0': asc_or_desc_bool=False elif asc_or_desc=='1': asc_or_desc_bool=True else: print('您的輸入有誤,請重新輸入!') sort() mode=input('請選擇排序方式(0:按總成績排序,1:按English成績排序,2:按Python成績排序,3:按Java成績排序)') if mode=='0': student_new.sort(key=lambda x: int(x['English'])+int(x['Python'])+int(x['Java']), reverse=asc_or_desc_bool) elif mode=='1': student_new.sort(key=lambda x:int(x['English']),reverse=asc_or_desc_bool) elif mode=='2': student_new.sort(key=lambda x: int(x['Python']), reverse=asc_or_desc_bool) elif mode=='3': student_new.sort(key=lambda x: int(x['Java']), reverse=asc_or_desc_bool) else: print('您的輸入有誤,請重新輸入!') sort() show_student(student_new) pass def total(): if os.path.exists(filename): with open(filename,'r',encoding='utf-8') as rfile: students=rfile.readlines() if students: print(f'一共有{len(students)}名學(xué)生') else: print('還沒有錄入學(xué)生信息!') else: print('暫未保存學(xué)生信息......') pass def show(): student_lst=[] if os.path.exists(filename): with open(filename,'r',encoding='utf-8') as rfile: students=rfile.readlines() for item in students: student_lst.append(eval(item)) if student_lst: show_student(student_lst) else: print('暫未保存過數(shù)據(jù)!') pass def save(stu_list): try: stu_txt=open(filename,'a',encoding='utf=8') except: stu_txt=open(filename,'w',encoding='utf-8') for item in stu_list: stu_txt.write(str(item)+'\n') stu_txt.close() def show_student(lst): if len(lst)==0: print('沒有查到學(xué)生信息,無數(shù)據(jù)顯示!') return #定義標(biāo)題顯示格式 format_title='{:^6}\t{:^12}\t{:^10}\t{:^10}\t{:^10}\t{:^8}' print(format_title.format('ID','姓名','English成績','Python成績','Java成績','總成績')) #定義內(nèi)容顯示格式 format_data='{:^6}\t{:^12}\t{:^10}\t{:^18}\t{:^14}\t{:^8}' for item in lst: print(format_data.format(item.get('id'),item.get('name'),item.get('English'),item.get('Python'),item.get('Java'),str(int(item.get('English'))+int(item.get('Python'))+int(item.get('Java'))))) pass def menum(): print('-------------------學(xué)生信息管理系統(tǒng)--------------------') print('-----------------------功能菜單------------------------') print(' 1.錄入學(xué)生信息') print(' 2.查找學(xué)生信息') print(' 3.刪除學(xué)生信息') print(' 4.修改學(xué)生信息') print(' 5.成績排序') print(' 6.統(tǒng)計學(xué)生總?cè)藬?shù)') print(' 7.顯示所有學(xué)生信息') print(' 0.退出系統(tǒng)') print('------------------------------------------------------') main()
4. ????? ????? .exe ?? ??? ?????
1. ?? ??? ???? dos ?? ?? pip install PyInstaller? ???? Enter ?? ????.
2. Enter: pyinstaller -F ?? ??? ???? ??,
3 Enter? ?? ? ?? ??? ? ???? ??? ??? .exe ??? ??? ????? ? ????.
? ??? Python?? ??? ?? ?? ?? ???? ???? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ?? ??? ??? ?? JavaScript? MediareCorder API? ?? PHP ???? ???? ?????. 2. PHP? ???? ?? ??? ???? STTAPI (? : Google ?? Baidu ?? ??)? ???? ???? ?????. 3. PHP? ???? AI ??? (? : OpenAigpt)? ????. 4. ?? ?? PHP? TTSAPI (? : Baidu ?? Google ?? ??)? ???? ??? ?? ??? ?????. 5. PHP? ?? ??? ??? ??? ??? ?? ?? ??? ?????. ?? ????? PHP? ?? ???? ?? ?? ?? ??? ??? ?????.

AI? ??? ??? ?? ?? ? ?? ???? ????? ?? ??? ??????. 1. Baidu, Tencent API ?? ?? ?? NLP ?????? ?? ??? AI ?? ?? API? ??????. 2. PHP? ? ?? guzzle? ?? API? ???? ?? ??? ??????. 3. ?? ????? ?? ?? ??? ???? ???? ???? ??? ??? ? ????. 4. ?? ?? ? ?? ???? ?? PHP-L ? PHP_CODESNIFFER? ??????. 5. ???? ????? ???? ?? ?? ??? ?????? ??? ??????. AIAPI? ??? ? ???, ?? ??, ?? ? PHP ?? ??? ??? ???. ?? ???? PSR ??? ???, ??? ????? ????, ?? ??? ???, ????? ??? ????, X? ???????.

Seaborn 's Loctplot? ???? ? ?? ?? ??? ??? ???? ??????. 2. ?? ???? sns.jointPlot (data = tips, x = "total_bill", y = "tip", ?? = "scatter")? ?? ?????. ??? ????? ?????? ??? ??? ?????. 3. ???? ?? ??? ??? = "reg"? ???? marginal_kws? ???? ?? ?? ???? ?????. 4. ??? ??? ? ?? "Hex"? ???? ?? ????.

AI ?? ??? ??? PHP ??????? ????? Core? ?? ??? ???? ??? AIAPI (? : Google, AWS ? Azure)? ???? HTTP ??? ?? ???? ??? JSON ??? ???? ?? ???? ??????? ???? ??? ? ?? ? ??? ???? ???? ???? ????. ?? ??? ??? ????. 1. ???, ??, ?? ?? ? ?? ???? ???? ??? AI ?? ?? API? ?????. 2. Guzzle ?? Curl? ???? ??? ??? ?? ??, ??? ? ?? ??? ??????. 3. ?? ?? ??, ?? ??, ?? ?? ?? ? ??? ???? ???? ?? ??? ?? ??? ??????. 4. API ?? ?? ? ??? ?? ??? ??? ?? ??

??? ??? ".join (Words)? ?? join () ???? ?? ? ? ????. 2. ?? ??? ???? ?? MAP (str, ??) ?? [str (x) forxinnumbers]??? ???? ???????. 3. ?? ?? ??? ???? ??? ??? ?????? ???? ?? ?? ? ? ????. 4. '|'.join (f "[{item}]"furiteminitems) ??? ?? join ()? ?? ? ??? ????? ??? ?? ??? ??? ? ????.

PyoDBC ?? : PipinStallPyODBC ??? ???? ?????? ??????. 2. SQLSERVER ?? : PYODBC.connect () ???? ?? ????, ??, ??????, UID/PWD ?? Trusted_Connection? ?? ? ?? ???? ???? SQL ?? ?? Windows ??? ?? ?????. 3. ??? ????? ?????? : pyodbc.drivers ()? ???? 'sqlserver'? ?? ? ???? ??? ????? ??? ???? ??? 'sqlserver ? Odbcdriver17? ?? ??? ???? ??? ????? ??????. 4. ?? ???? ? ?? ??

pandas.melt ()? ???? ?? ???? ? ???? ???? ? ?????. ?? ID_VARS? ???? ? ? ??? ???? ????. ??, 4.Value_name = 'score'? ?? ?? ? ? ??? ???? ????? ??, ?? ? ??? ??? ? ?? ?????.

pythontanbeoptimizedformemory-boundoperations? Headgroughgenerations, ??? ? ??? ??, ? ManagingObjectLifetimes.first, usegeneratorsinsteadoflistStoprocessLargedAtasetSoneitematime, theintintomemory.second? ?????
