zoukankan      html  css  js  c++  java
  • python 常用方法

    python 常用方法

    type使用方式及作用?

    # 方法:print(type(任意数据类型))
    # 作用:查看数据类型
    print(type(1))
    # 输出<class 'int'> 整型
    
    print(type("a"))
    # 输出<class 'str'>字符串型
    
    print(type(True))
    print(type(False))
    # 输出<class 'bool'>布尔值型
    
    print(type([1,2]))
    # 输出<class 'list'>列表型
    
    print(type((1,)))
    # 输出<class 'tuple'>元组型
    
    print(type({"1":2,"2":"3"}))
    # 输出<class 'dict'>字典型
    
    print(type({"1","2"}))
    # 输出<class 'set'>集合型
    

    id的使用方式及作用?

    # 使用方法:print(id(任意数据类型))
    # 作用:获取内存地址
    print(id({"1","2"}))
    # 输出 一串数字
    

    len求长度

    lst = [1,2,3,4,5]
    使用方法for I in len(last)
    

    locals查看当前文件的所有

    print(locals())
    # 输出
    {'__name__': '__main__', '__doc__': None, '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x1064a2f28>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': '/Users/zhangshan/Desktop/01 自定义模块.py', '__cached__': None, 'test': <module 'test' from '/Users/zhangshan/Desktop//test.py'>}
    
    
  • 相关阅读:
    python使用阿里云oss-sdk
    flask-文件上传的使用
    flask-migrate的基本使用
    flask-script的基本使用
    flask-sqlalchemy的基本使用
    alembic的常用参数
    sqlchemy查询的其他操作
    orm层面的删除的注意事项
    C#获取数据库中的Instance
    SOA Demo
  • 原文地址:https://www.cnblogs.com/zhangshan33/p/11172435.html
Copyright © 2011-2022 走看看