首页 > 编程语言 > 详细

python第二天基础1-1

时间:2015-12-10 23:50:13      阅读:218      评论:0      收藏:0      [点我收藏+]

一、作用域

对于变量的作用域,执行声明并在内存中存在,该变量就可以在下面的代码中使用。

if 1==1:
    name = ‘wupeiqi‘
print  name

 二、三元运算

result = 值1 if 条件 else 值2   如#果条件成立,值1付给result否则值2付给result

如果条件为真:result = 值1
如果条件为假:result = 值2

name =  ‘sb‘  if 1==1 else ‘2b‘

 

input = raw_input()

result = ‘2b‘  if input ==‘alex‘ else ‘haoren‘

 

python第二天基础1-1

原文:http://www.cnblogs.com/sundi/p/5037628.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!