python 笔记1
来源:互联网 发布:百家cms分销系统 编辑:程序博客网 时间:2024/06/08 03:12
一种解释语言,类似与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
- python学习笔记1
- python学习笔记(1)
- python学习笔记(1)
- python笔记1
- Python笔记(1)
- Python学习笔记1
- python笔记1
- Python学习笔记1
- Python 学习笔记(1)
- python笔记1
- Python初学笔记(1)
- python笔记1
- python笔记《1》
- 《Think Python》笔记1
- Python 基础笔记(1)
- Python学习笔记1
- Python 笔记1
- python学习笔记【1】
- 用minicom 进行自动化测试 --通过bash脚本操作minicom
- xp 下硬盘安装fedora 15
- 如何写出漂亮的代码 (转载)
- makefile 学习笔记2
- 剖析Linux系统启动过程 (转)
- python 笔记1
- python 学习笔记2
- 天外飞仙级别的Linux Shell命令
- 教你系统工具EasyBcd怎么用
- 非常简单的Python HTTP服务
- 中兴 V880谷歌地图中谷歌纵横不能用的问题
- linux 主机启动到系统运行过程 (笔记)
- linux 登录后profile等的执行及顺序
- pci总线和局部总线