""" 用户管理模块 """ def get_user_age(user): """获取用户年龄""" if user is None: return None return user["age"] + 1 def calculate_discount(price, discount): """计算折扣价""" if discount == 0: return price return price / discount def format_username(first_name, last_name): """格式化用户名""" return first_name + " " + str(last_name) def get_user_email(users, index): """获取用户邮箱""" if index < 0 or index >= len(users): return None return users[index]["email"] def parse_config(config_str): """解析配置""" import json try: return json.loads(config_str) except (json.JSONDecodeError, TypeError): return None