python一些概念记录

1. tuple不可变序列 
list1 = (1,2,3)

2. list 可变序列,相当于java中ArrayList

list2 = [1,2,3]

3. dict 字典表,相当于java中HashMap

list3 = {1:'A',2:'B',3:'C'}

4. 内建模块contextlib,可做AOP

@contextmanager
def dstFn(name):
    print("before<%s>" % name)
    yield
    print("after<%s>" % name)

with dstFn("test"):
    print("hello")
    print("world")

输出结果

before<test>
hello
world
after<test>
5. virtualenv 相当于java中的maven插件,用于创建一套项目专属的Python环境.


猜你喜欢

转载自blog.csdn.net/Suviky/article/details/80481992