python 老男孩員工信息腳本_第1頁
python 老男孩員工信息腳本_第2頁
python 老男孩員工信息腳本_第3頁
python 老男孩員工信息腳本_第4頁
python 老男孩員工信息腳本_第5頁
已閱讀5頁,還剩1頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、1、從文件讀取用戶信息登錄2、管理登錄用戶,添加刪除和修改3、管理用戶信息,進一步刪除和修改4、使用的知識如下5,Json repr文件6,Python可以傳遞給repr()或str()函數(shù),將任意值轉(zhuǎn)換為字符串。Str()函數(shù)用于將值轉(zhuǎn)換為適合人類讀取的形式,而repr()函數(shù)則轉(zhuǎn)換為解釋器可以讀取的形式7、Json簡單數(shù)據(jù)類型的encoding和decodingImportjsonStr=admin : jine,test :Encodedjson=json.dumps(str)Printrepr(obj)PrintencodejsonJson.dumps()方法返回str對象encode

2、djson。接下來,將encodedjson作為decode運行,以使用需要獲取和使用原始數(shù)據(jù)的json.loads()函數(shù)。decode JSON=JSON . loads(encoded JSON)打印類型(decode JSON)Printdecodejson4key1Printdecodejson8個,9、腳本如下10,# -*- coding: UTF-8 -*-11,#!C:Python27Python.exe12、import JSON13、import OS14,# print 0331;31;40米15,#print 0330m16,def info(name):17,F(xiàn)P=

3、file(“BBB . txt”,“r”)18,line=fp.readlines()19,info=(eval(line0)20,if name in info.keys():21,return infoname22,fp.close()23,def lock(name):24,F(xiàn)P=file(lock.txt , a )25,str=%sn% name26,fp.write(str)27,fp.close()28,def readlock():29,F(xiàn)P=file(lock.txt , r )30,str=fp.readlines()31,return repr(str)32,fp.clo

4、se()33,def admininfo():34,F(xiàn)P=file(bbb.txt , r )35,line=fp.readlines()36,info=(eval(line0)37、return info38,fp.close()39,def adminadd(aname,apwd):40,info=admininfo()41,F(xiàn)P=open(bbb.txt , w )42,infoaname=apwd43,info=repr(info)44,fp.write(info)45,fp.close()46,print add or modify % s success % aname47,def

5、 admindel(aname):48,info=admininfo()49,F(xiàn)P=open(bbb.txt , w )50,戴爾信息aname51,info=repr(info)52,fp.write(info)53,fp.close()54,print“del % s success”% aname55,def admin():56,while True:57、print“please select”58,print tt1.userlist 59,print tt2.adduser 60,print tt3.miduser 61,print tt4.deluser 62,print tt

6、5.exit 63,ten=None64、try:65,ten=int(raw _ input( entry your selected : )66、except:67,print please entry 1 or 2 or 3 or 4 or 5 68,if type(ten)=int:69,if ten=1:70,adminlist=admininfo()71,I=172,for key in adminlist:73,print t t% s% I,key,admin list key74,I=175,elifften=2336076,while True:77,# # # #78、w

7、hile True:79,name=raw _ input( entry new username : )80,if len(name)=0:81,print please entry new username!82、continue83、else:84,中斷85,while True:86,pwd=raw _ input( entry new password : )87,if len(pwd)=0:88,print please entry new password!89、continue90、else:91,中斷92,if adminadd(name,pwd):93,print add

8、user success 94,中斷95,# # #96,eliffen=3:97,while True:98,# # # #99,while True:100,name=raw _ input( entry old username : )101,if len(name)=0:102,print please entry old username!103,continue104、else:105,break106,while True:107,pwd=raw _ input( entry new password : )108,if len(pwd)=0:109,print please e

9、ntry new password!110,continue111,else:112,中斷113,adminadd(name)114,中斷115,# # #116,elifften=4:117,while True:118,# # # #119,while True:120,name=raw _ input( entry del username : )121,if len(name)=0:122,print please entry del username!123,continue124、else:125,中斷126,admindel(name)127,中斷128,# # #129,eli

10、fften=5:130,中斷131、else:132,print please entry 1 or 2 or 3 or 4 or 5 133,繼續(xù)134,def emp():135,while True:136,print please select 137,print tt1.userlist 138,print tt2.adduser 139,print tt3.miduser 140,print tt4.deluser 141,print tt5.exit 142,ten=無143、try:144,ten=int(raw _ input( entry your selected : )145、except:146,print please entry 1 or 2 or 3 or 4 or 5 147,if type(ten)=int:148,if ten=1:149,print“user list”150,elifften=23360151,print“adduser”152,eliffen=3:153,print

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論