在Python中输出个人信息可以通过以下几种方式实现:
1. 使用`print`函数直接输出:
name = input("请输入您的姓名:")age = input("请输入您的年龄:")gender = input("请输入您的性别:")address = input("请输入您的地址:")print("个人信息如下:")print("姓名:", name)print("年龄:", age)print("性别:", gender)print("地址:", address)
2. 使用格式化字符串输出:
name = "张三"age = 20gender = "男"address = "北京市"print("个人信息如下:")print("姓名:%s" % name)print("年龄:%d" % age)print("性别:%s" % gender)print("地址:%s" % address)

3. 使用`format`方法进行格式化输出:
name = "小明"age = 19height = 180.42weight = 50.2print("个人信息如下:")print("姓名:{}".format(name))print("年龄:{}".format(age))print("身高:{:.2f}".format(height))print("体重:{:.2f}".format(weight))
4. 使用f-string(Python 3.6及以上版本支持)进行格式化输出:
name = "李四"age = 25job = "程序员"hobby = "篮球"print(f"个人信息如下:")print(f"姓名:{name}")print(f"年龄:{age}")print(f"职业:{job}")print(f"爱好:{hobby}")
