Python练习随笔01

作业二:
首先需要知道我们要用到什么额外知识:python文件的读写。网上查找资料得到如何运用:
http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386820066616a77f826d876b46b9ac34cb5f34374f7a000
随后画出流程图:

然后就开始我们的编程。
#! user/bin/env python # -*- coding:utf-8 -*- # Author:Sun import os import linecache account = input("please input your account:") password = input("please input your password:") vaccount = "sun" vpassword = "qwe789" with open('E:\我的文档\pythonproject\day1\lock.txt','r') as rfile: for line in rfile.readlines(): if line == account: print("your account have been locked") exit() count = 0 while count<2: if account == vaccount and password == vpassword: print("Welcome!") exit() else: print("wrong account or password") account = input("please input your account:") password = input("please input your password:") count = count + 1 else: with open('E:\我的文档\pythonproject\day1\lock.txt', 'w') as wfile: wfile.write(account) print("your account have been locked") exit()

浙公网安备 33010602011771号