码迷,mamicode.com
首页 > 编程语言 > 详细

python 基础 if语句

时间:2018-01-18 23:02:05      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:==   isp   图片   python   inpu   就会   指定   mon   python 基础   

技术分享图片
sex = input("please input your gender:")
if sex == "man":
    print("I would like to makefriend with you")
elif sex == "girl":
    print("I would like have a little monkey with you")
else:
    print("are you kidding me?")
guess sex game

python里面采用强制缩进,来指定作用域。类似于java里面的{}括起来的部分。如果没有缩进的话,python就会语法错误。
python只会认为要执行if下有缩进的那些语句。

python 基础 if语句

标签:==   isp   图片   python   inpu   就会   指定   mon   python 基础   

原文地址:https://www.cnblogs.com/jiaaoblog/p/8313215.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!