Python文法練習--字串格式化

黄舟
發布: 2016-12-28 17:23:41
原創
1418 人瀏覽過

#!/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中文網(www.php.cn)!


相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!