python基础知识-day8(函数实战)
2024-09-08 04:28:25
1 def out():
2 username=input("请输入用户名:\n")
3 password=input("请输入密码:\n")
4 return username,password
5 def registered():
6 username,password=out()
7 temp=username+"|"+password
8 with open(file="log.txt",mode="w",encoding="utf-8") as f:
9 f.write(temp)
10 def login():
11 username,password=out()
12 with open(file="log.txt",mode="r",encoding="utf-8") as f:
13 lists=f.read().split("|")
14 if username==lists[0] and password==lists[1]:
15 return True
16 else:
17 print("你登录的账户有误,请重新登录")
18 def profile():
19 with open(file="log.txt",mode="r",encoding="utf-8") as f:
20 lists=f.read().split("|")
21 print("欢迎访问{0}个人主页".format(lists[0]))
22 def main():
23 while True:
24 try:
25 f=int(input("1、注册 2、登录 \n"))
26 if f==1:
27 registered()
28 elif f==2:
29 if login()==True:
30 profile()
31 else:
32 print("请输入正确的账户密码")
33 else:
34 break
35 except:
36 continue
37
38 if __name__ == '__main__':
39 main()
最新文章
- 基础拾遗------webservice详解
- 手机APP创建桌面快捷方式
- js统计,然后去重例子
- 用帝国CMS时遇到的问题
- 条件随机场matlab程序下载
- salesforce 零基础学习(三十)工具篇:Debug Log小工具
- SQL一次查出多个字段的COUNT值
- fastReport 运行时设计报表 (mtm)
- Keepalived安装使用详解
- 搭建SpringMVC+MyBatis开发框架一
- MAC OSX 下安装 CTAGS
- html5 list属性、autocomplete属性、pattern属性
- Shader的使用
- chattr 命令详解
- webpack初探 - (一)
- Python_内置函数2_44
- 反向代理负载均衡之APACHE
- [转载]解决linux 下多线程错误 undefined reference to `sem_init'
- HTML与XHTML的差别(转自)http://jingyan.baidu.com/article/597035521c31ed8fc007400a.html
- 【Android】amr播放