• Python学习————作业


    1、编写文件修改功能,调用函数时,传入三个参数(修改的文件路径,要修改的内容,修改后的内容)既可完成文件的修改

    2、编写tail工具

    def tail(x):
        with open(x, mode='rt', encoding='utf-8') as f:
            for i in f:
                print('原文件:', i)
                print('新文件:')
            while True:
                res = f.readline()
                if len(res) == 0:
                    continue
                else:
                    print(res)
    
    
    tail('x.txt')
    

    3、编写注册登录功能

    def user_register():
        print('注 册')
        user = input('请输入帐号: ')
        password = input('请输入密码:')
        with open(r'userlist.txt', mode='at', encoding='utf-8') as f:
            f.write(f'{user}:{password:}
    ')
    
    
    user_register()
    
    
    def login():
        print('登 录')
        userinfo = input('请输入帐号: ')
        pwd= input('请输入密码:')
        with open(r'userlist.txt', 'r', encoding='utf-8') as f:
            for line in f:
                username, password = line.strip().split(":")
                if username == userinfo and pwd == password:
                    print("登录成功")
                    break
            else:
                print("输入错误")
    
    
    login()
    
  • 相关阅读:
    WML1.1[zt]
    Collections sort() 合并排序
    PowerBuliderconnect the oracle database
    window.location.reload;刷新
    PowerBuliderWorking with validation rules
    PowerBulider create database
    Jstl Core标签
    页面验证
    El表达式详解
    servlet的生命周期
  • 原文地址:https://www.cnblogs.com/x945669/p/12513691.html
Copyright © 2020-2023  润新知