#!/usr/bin/env python # -*- coding:utf8 -*- w_sex = "女" m_sex = "男" w_age = 23 m_age = 25 sex_input = input("请输入您的性别:").strip() age_input = int(input("请输入您的年龄:")) if sex_input == w_sex and age_input >= w_age: print ("您的信息如下:\n性别:%s\n年龄:%s\n您属于晚婚年龄" %(sex_input,age_input)) elif sex_input == m_sex and age_input >= m_age: print ("您的信息如下:\n性别:%s\n年龄:%s\n您属于晚婚年龄" %(sex_input,age_input)) else: print ("输入错误,系统退出")
以上就是Python语法练习--字符串格式化的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!
已抢66294个
抢已抢36123个
抢已抢20014个
抢