vim if.py //編譯以.py結尾的文件 #!/usr/bin/env python //程序內容開始 #File: if.py print 'Hello, how old are you?' age = int(raw_input('Please input your age:')) //定義age爲整數型 if age == 28: print "You're at the age of marriage!" elif age > 28 and age <35: print "You must go on a blind date now." elif age < 28: print "You're still young and good to learn!" else: print "Sorry, I don't know your age!" //程序內容結束 chmod +x if.py //賦予文件可執行權限 ./if.py //執行程序
python---if語句
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.