当前位置: 首页 > news >正文

第四次作业

第一题:

import os def traverse_directory(path): for item in os.listdir(path): item_path = os.path.join(path, item) if os.path.isfile(item_path): print(item_path) elif os.path.isdir(item_path): traverse_directory(item_path)

第二题:

import hashlib import json import os USER_FILE = 'users.json' def hash_password(password): return hashlib.md5(password.encode('utf-8')).hexdigest() def register_user(username, password): if not os.path.exists(USER_FILE): users = {} else: with open(USER_FILE, 'r') as f: users = json.load(f) if username in users: print("用户名已存在。") return False users[username] = hash_password(password) with open(USER_FILE, 'w') as f: json.dump(users, f) print("注册成功。") return True def login_user(username, password): if not os.path.exists(USER_FILE): print("用户不存在。") return False if users[username] == hash_password(password): print("登录成功") return True else: print("密码错误。") return False
http://www.cnnetsun.cn/news/128541.html

相关文章:

  • 差模干扰(Differential Mode Interference, DMI)与共模干扰(Common Mode Interference, CMI)全面解析
  • Kotaemon PPT内容抽取:演示文稿知识化方案
  • Ventoy 全能启动盘制作指南:告别繁琐,拥抱高效
  • 期末复习-改错题
  • 小红书私域引流天花板:专属卡片 + 多号聚合,安全又高效
  • 机器学习(深度学习)与教育类比
  • pnpm 深度解析:下一代包管理工具的原理与实践
  • 小程序项目之食堂线上预约点餐系统源码(源码+文档)
  • 【论文阅读】POP-3D:Open-Vocabulary3DOccupancyPrediction fromImages
  • 嵌入式 UART 调试遇阻?关键一步没人提
  • AI大模型使用GPU加速(python、CUDA、pytorch)
  • 拒绝无效内卷!2025年网文圈公认好用的【写小说软件】红黑榜大公开
  • [特殊字符] 2025全网最全AI写小说软件生成器测评大合集|附ai生成小说使用技巧
  • Kotaemon法律援助机器人公益项目启动
  • 沉浸式LED显示屏LED大屏幕生产厂家
  • pg配置国内数据源安装
  • AI知识图谱:一张图看懂AI学习全路径
  • Kotaemon命名实体识别模块扩展技巧
  • 1.4 从0到1:AIGC产品应用全景深度解析
  • Kotaemon自然语言生成(NLG)模板优化技巧
  • 【AI-提效】svn diff 配置 bcompare
  • Kotaemon GPU资源占用监测:显存与算力消耗实测
  • Kotaemon SEO友好设计:静态内容提取技巧
  • Kotaemon CI/CD集成实践:持续交付智能代理
  • 【完整源码+数据集+部署教程】数码管定位系统源码分享[一条龙教学YOLOV8标注好的数据集一键训练_70+全套改进创新点发刊_Web前端展示]
  • 文档处理大杀器!NVIDIA开源<1B参数模型,支持表格提取和版式分析,太强了!
  • Kotaemon能否用于保险条款解读?复杂文本简化能力
  • 23、跨平台 Unix 系统管理与自动化工具实践
  • 30、Python 并发编程:线程、进程与调度全解析
  • rt-linux下的“硬实时”的hrtimer通知机制