python 笔记1

11 what is python
    一种解释语言,类似与perl,具有简单,易移植等优势,成为程序员的最爱

2 hello world

    #!/usr/bin/python
    print 'hello world'
    print r"hello \n"  //  前边加r,使输出自然语言,即\n不代表换行,只是字符;
    print "hello world \n"
     想bash编程一样,开头为要调用的解释工具;
 
3 python 的分支结构 if
    例子:
       i = len('hello world')
       if i == 11:
          print "that's right"
       else:
          print "no"
    注意 if和else 后有‘:’ ,还有,if后的语句有缩进,没缩进的话会报错,
    第一次见到这种报错;
4 for循环
    for i in range(1, 5):
        print i
5 关于缩进
    for i in range(1, 5)
        print i
        print 'hello'
    输出结果:
    1
    hello
    2
    hello
    3
    hello
    4
    hello
    另一个程序
    for i in range(1, 5)
        print i
    print 'hello'
    输出结果:
    1
    2
    3
    4
    hello
    python中没有C总的‘{}',也没有bash中的if fi,只能用缩进表示模块关系
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值