Chinaunix首页 | 论坛 | 博客
  • 博客访问: 687441
  • 博文数量: 111
  • 博客积分: 2109
  • 博客等级: 上尉
  • 技术积分: 1124
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-25 12:11
个人简介

通信码农,Emacs爱好者,业余IOS程序员,更业余的PM

文章分类

全部博文(111)

文章存档

2018年(2)

2016年(2)

2015年(2)

2014年(13)

2013年(21)

2012年(71)

分类: Python/Ruby

2012-09-03 16:49:49

1.) python是一种解释语言。python源文件是以py为后缀。

2.) 跟shell 脚本类似
python的源文件头要加入#!usr/bin/python ,

3.) 然后进入源文件目录 chmod a x ,执行跟shell脚本一样./name.py

4.)python 对于空格的要求非常严格。不能跟类C语言一样随意添加空格,末尾没有;分割
python依靠缩写区分代码块。

5)没有switch语句,多重选择使用if ...elif...  else...

if guess == number:
    print 'Congratulations, you guessed it.' # New block starts here
    print "(but you do not win any prizes!)" # New block ends here
elif guess < number:
    print 'No, it is a little higher than that' # Another block
    # You can do whatever you want in a block ...
else:
    print 'No, it is a little lower than that' 
    # you must have guess > number to reach here
一般需要更多的时候利用字典来解决

阅读(727) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~