Python语言学习小结

来源:互联网 发布:小管家进销存软件 编辑:程序博客网 时间:2024/05/16 11:53

1. 字符串可以用""或者'':

print "this is fun"

print 'Yay!Printing.'

2.代码以行和4个空格,对齐标示开始和结束

3.注释:#

4.str之间用"+"和","连接,"+"就是直接concat,","会加上一个空格 并且print后面加上","会和下面一个print同一行

5.数据类型:str,number和list输出时(%d,%s,%r)

6.使用pydoc查看方法使用说明

7.from module import XXX

8.fun,if,while,for,method,class etc后面都是以":"结尾

9.输出时候%var或者%(var1,var2,var3,...)

10.script,filename=argv

11.function:同一方法被def多次后,最后一次会overwrite前面的,一个fun可以返回多个结果,参数加*标示多个参数

12.函数指针:cities['_find'] = find_city

13.list,map for a in list

14.classe:

class TheThing(object):

def __init__(self):

每个method第一个参数都必须为self,且必不可少

new Class:a = TheThing();

15 map key:if a in list

16base function:

raw_input("asdasd")

open(filename),open(filename,"w")

a.read();

a.truncate();

a.seek(n)

a.close();

a.split("asdasd","a")

sorted(list)

a.pop(0),a.pop(-1)

range(1,100)

elements.append(j)



16.python api:http://docs.python.org/c-api/