🛠️ToolsShed

卡路里计算器

根据年龄、体重、身高和活动量计算每日卡路里需求。

此数据基于Mifflin-St Jeor公式估算。如需个性化营养建议,请咨询医疗专业人员或注册营养师。

卡路里计算器根据您的个人特征和健身目标估算您的每日卡路里需求。它将您的基础代谢率(静息时燃烧的卡路里)与您的活动水平相结合,找到维持卡路里,然后根据您的目标(减脂、维持或增肌)上下调整该数字。

输入您的年龄、身高、体重、性别和活动水平,然后选择您的目标。该工具根据广泛认可的营养指南显示推荐的每日卡路里、蛋白质、碳水化合物和脂肪目标。

这些数字是起始估算。每个人的新陈代谢略有不同,因此请追踪几周内的体重和能量水平,如果结果与预期不符,请调整 100-200 卡路里的摄入量。

常见问题

代码实现

def bmr_mifflin(weight_kg, height_cm, age, sex):
    """
    Mifflin-St Jeor BMR formula.

    Parameters:
        weight_kg - body weight in kilograms
        height_cm - height in centimetres
        age       - age in years
        sex       - 'male' or 'female'

    Returns Basal Metabolic Rate in kcal/day.
    """
    bmr = 10 * weight_kg + 6.25 * height_cm - 5 * age
    return bmr + 5 if sex == "male" else bmr - 161


ACTIVITY_MULTIPLIERS = {
    "sedentary":    1.2,   # little or no exercise
    "light":        1.375, # 1-3 days/week
    "moderate":     1.55,  # 3-5 days/week
    "active":       1.725, # 6-7 days/week
    "very_active":  1.9,   # twice/day or physical job
}


def tdee(weight_kg, height_cm, age, sex, activity_level="moderate"):
    """Total Daily Energy Expenditure = BMR × activity multiplier."""
    b = bmr_mifflin(weight_kg, height_cm, age, sex)
    return b * ACTIVITY_MULTIPLIERS[activity_level]


def macros(calories, protein_pct=0.30, carb_pct=0.40, fat_pct=0.30):
    """
    Split calories into macronutrient grams.
    Default split: 30% protein / 40% carbs / 30% fat.
    protein & carbs = 4 kcal/g; fat = 9 kcal/g.
    """
    return {
        "protein_g": calories * protein_pct / 4,
        "carbs_g":   calories * carb_pct   / 4,
        "fat_g":     calories * fat_pct    / 9,
    }


# Example: 30-year-old male, 80 kg, 175 cm, moderately active
b = bmr_mifflin(80, 175, 30, "male")
t = tdee(80, 175, 30, "male", "moderate")
m = macros(t)

print(f"BMR:            {b:.0f} kcal/day")
print(f"TDEE (moderate): {t:.0f} kcal/day")
print(f"Protein:        {m['protein_g']:.0f} g")
print(f"Carbs:          {m['carbs_g']:.0f} g")
print(f"Fat:            {m['fat_g']:.0f} g")

# Weight-loss / gain targets
print(f"\nWeight loss (-500 kcal): {t - 500:.0f} kcal/day")
print(f"Weight gain (+500 kcal): {t + 500:.0f} kcal/day")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.