zoukankan      html  css  js  c++  java
  • vars(),__main__,%,format

    """
    iaksdhkasdh
    """
    #vars()返回对象object的属性和属性值的字典对象。
    print(__doc__)#注释
    print(__file__)#路径
    from lib import account
    print(account.__package__)#当前py文件在哪个文件夹下
    print(vars())
    print(account.__cached__)#缓存,pyc文件
    def xx():
    print("执行")
    #只有本文件执行时,name等于main,否则等于模块名
    #如果不写的话,换一个文件导入本模块后,文件执行模块里就执行
    #xx() import 模块,等于加载模块的全部进缓存
    if __name__ == '__main__':
    xx()
    # %[(name)][flags][width].[precision]typecode
    # s = "i am %s,age %d" % ('alex',18)#s字符串d数字
    # s = "i am %(n1)+10s" % {"n1":"jbk"}
    # s = "i am %.1f" % 1.33#保留一位小数
    #s = "i am %.1f %%" % 50.33#当字符串存在格式化标志时,用%%表示%

    #[[fill] align] [sign] [#] [0] [width][,] [.precision][type]
    #空白填充 对齐方式<>^ +-空格 进制 引索 宽度 为数字添加分隔符 精度 类型
    # tpl = "i am {}, age {}, {}".format("seven", 18, 'alex')
    # tpl = "i am {}, age {}, {}".format(*["seven", 18, 'alex'])
    # tpl = "i am {0}, age {1}, really {0}".format("seven", 18)
    # tpl = "i am {0}, age {1}, really {0}".format(*["seven", 18])
    # tpl = "i am {name}, age {age}, really {name}".format(name="seven", age=18)
    # tpl = "i am {name}, age {age}, really {name}".format(**{"name": "seven", "age": 18})
    # tpl = "i am {0[0]}, age {0[1]}, really {0[2]}".format([1, 2, 3], [11, 22, 33])
    # tpl = "i am {:s}, age {:d}, money {:f}".format("seven", 18, 88888.1)
    # tpl = "i am {:s}, age {:d}".format(*["seven", 18])
    # tpl = "i am {name:s}, age {age:d}".format(name="seven", age=18)
    # tpl = "i am {name:s}, age {age:d}".format(**{"name": "seven", "age": 18})
    # tpl = "numbers: {:b},{:o},{:d},{:x},{:X}, {:%}".format(15, 15, 15, 15, 15, 15.87623, 2)
    # tpl = "numbers: {0:b},{0:o},{0:d},{0:x},{0:X}, {0:%}".format(15)
    # tpl = "numbers: {num:b},{num:o},{num:d},{num:x},{num:X}, {num:%}".format(num=15)
  • 相关阅读:
    PHP的跨域问题
    Linux常用命令
    搭建vagrant开发环境
    php 循环从数据库分页取数据批量修改数据
    Mac搭建pyhton+selenium+pycharm实现web自动化测试
    Mac 安装python 3.*新版本的详细步骤
    pycharm最新版本激活码(永久有效) python安装教程
    PHP操作redis 【转】
    php将图片存储在阿里云oss存储上
    Mac系统终端命令行不执行命令解决方法(command not found)
  • 原文地址:https://www.cnblogs.com/currynashinians000/p/8639158.html
Copyright © 2011-2022 走看看