作業3月13號

2022-09-06 13:09:25 字數 3305 閱讀 7729

#1、編寫檔案copy工具

a_file = input('

請輸入複製位址》

').strip()

b_file = input('

請輸入貼上位址》

').strip()

with open(r'{}

'.format(a_file),mode='

rt',encoding='

utf-8

') as f1,\

open(r'{}

'.format(b_file),mode='

wt',encoding='

utf-8

') as f2:

res =f1.read()

f2.write(res)

#2、編寫登入程式,賬號密碼來自於檔案

inp_name = input('

請輸入你的賬號:

').strip()

inp_pwd = input('

請輸入你的密碼:

').strip()

with open(r

'user.txt

',mode='

rt',encoding='

utf-8

') as f:

for x in

f: username,password=x.strip().split('='

)

if inp_name == username and inp_pwd ==password:

print('

登入成功')

break

else

:

print('

賬號或密碼錯誤

')

#3、編寫註冊程式,賬號密碼來存入檔案

name = input('

請輸入你的賬號:

').strip()

pwd = input('

請輸入你的密碼:

').strip()

with open(r

'user.txt

',mode='

at',encoding='

utf-8

') as f:

f.write(

'{}={}\n

'.format(name, pwd))

with open(r'

a.txt

',mode='

rt',encoding='

utf-8

') as

f:

for b in

f: username, password = b.strip().split('='

)

for a in range (3

): inp_name=input('

請輸入你的賬號:')

inp_pwd = input('

請輸入你的密碼:')

if inp_name == username and inp_pwd ==password:

print(

'登入成功')

break

else

: print(

'登入失敗:')

else

: print(

'輸錯三次,已退出

')

if cmd == '0':

break

elif cmd == '1':

# 登入功能**(附加:可以把之前的迴圈巢狀,三次輸錯退出引入過來)

pass

elif cmd == '2':

# 註冊功能**

pass

else:

print('輸入的命令不存在')

# 思考:上述這個if分支的功能否使用其他更為優美地方式實現

msg = """0退出

1登入2註冊

"""print(msg)

cmd = input('

請輸入命令編號》:

').strip()

ifnot cmd.isdigit():

print(

'必須輸入命令編號的數字,傻叉')

continue

if cmd == '0'

:

break

elif cmd == '1'

:# 登入功能**(附加:可以把之前的迴圈巢狀,三次輸錯退出引入過來)

with open(r

'b.txt

', mode='

bt', encoding='

uft-8

') as

k:

for info in

k: username, password = info.strip().split('='

)

for count in range(3

): inp_name=input('

請輸入賬號')

inp_pwd =input('

請輸入密碼')

if username==inp_name and password==inp_pwd:

print(

'登入成功')

break

else

: print(

'請重新輸入')

else

: print(

'輸出三次,退出')

elif cmd == '2'

:# 註冊功能**

with open(r

'b.txt

', mode='

at', encoding='

uft-8

') as

i: inp_name = input('

請輸入賬號')

inp_pwd = input('

請輸入密碼')

i.write({}={}.format(inp_name,inp_pwd))

print(

'註冊成功')

else

: print(

'輸入的命令不存在

')

3月13號工作

今天的工作 1 完成了修改浮層的值可以修改div的值 1 1在js中定義事件在 首先獲得到每個單元格的id在把浮層的值賦值給單元格的值 document.getelementbyid submit buttons onclick function else document.getelementby...

3月13號筆記

el表示式 在日常開發中,我們想要驗證乙個字串是否符合我們的要求,用到正規表示式可以很方便的滿足我們的需求 例子 js中 function pricereg value g,只保留第乙個.清除多餘的.value value.replace replace g,replace 去掉特殊符號 if va...

3月7號 3月13號內容總結

內容 作用 物件儲存字串 與字元陣列相比所具有的優勢 物件能夠與一般變數一樣進行加法運算 將字元連線在乙個變數中 以及使用條件表示式等 string類物件定義 string x 賦值 string x hello x hello x world cin x getline cin,x 可輸入空格而c...