python学习
1.字符串用单引号
2.print不用括号
3.print用%
例如 print "%s is number %d!" % ("Python", 1)
4.不用大括号,而用缩进
5.if判断时,不用小括号括起条件,然后加上冒号:
6.字符串用[]提取时,-1代表结束的字符
7.if语句
if expression:
if_suite
if expression:
if_suite
else:
else_suite
if expression1:
if_suite
elif expression2:
elif_suite
else:
else_suite
8.while循环
while expression:
while_suite
9.for in
for eachNum in range(3):
... print eachNum
10 help
help(raw_input)
11.print的逗号
print eachLine, #意思是不换行
12.open文件
fobj = open('test.py', 'r')
for eachLine in fobj:
print eachLine,
fobj.close()
13.定义函数
def function_name([arguments]):
"optional documentation string"
function_suite