if __name__ == '__main__':
a = ''
b = 'True'
c = 'False'
#方法一:为真时的结果 if 判定条件 else 为假时的结果
d = b if a else c
print('方法一输出结果:' + d)
#方法二:判定条件 and 为真时的结果 or 为假时的结果
d = a and b or c
print('方法二输出结果:' + d)
#以上两种方法方法等同于if ... else ...
if a:
d = b
else:
d = c
print('if语句的输出结果:' + d)
x = [x for x in range(1,10)] print(x) y =[] result = True if 12 not in x else False # this is the best way print(result) result = True if not 12 in x else False # this way just like as " (not 12) in x" print(result) print(x is y) print(x is not y) # this is the best way print(not x is y) # this way just like as " (not x ) is y" ,so upper is the best way result = 2 if 1 < 2 else 5 if 4 > 5 else 6 # just as 1 > 2 ? 2 : 4 > 5 ? 5 : 6 print(result)
name='' while not name: name=raw_input(u'请输入姓名:') print name
a = False if not a: (这里因为a是False,所以not a就是True) print "hello"
a = 5 b = [1, 2, 3] if a not in b: print "hello"
>>> x = 1 >>> not x False >>> x = [1] >>> not x False >>> x = 0 >>> not x True >>> x = [0] # You don't want to fall in this one. >>> not x False
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有