zoukankan      html  css  js  c++  java
  • 内置函数-format()

    # 字符串串
    print(format('test', '<20')) # 左对⻬齐
    print(format('test', '>20')) # 右对⻬齐
    print(format('test', '^20')) # 居中
    # 数值
    print(format(3, 'b')) # ⼆二进制
    print(format(97, 'c')) # 转换成unicode字符
    print(format(11, 'd')) # ⼗十进制
    print(format(11, 'o')) # ⼋八进制
    print(format(11, 'x')) # ⼗十六进制(⼩小写字⺟母)
    print(format(11, 'X')) # ⼗十六进制(⼤大写字⺟母)
    print(format(11, 'n')) # 和d⼀一样
    print(format(11)) # 和d⼀一样
    # 浮点数
    print(format(123456789, 'e')) # 科学计数法. 默认保留留6位⼩小数
    print(format(123456789, '0.2e')) # 科学计数法. 保留留2位⼩小数(⼩小写)
    print(format(123456789, '0.2E')) # 科学计数法. 保留留2位⼩小数(⼤大写)
    print(format(1.23456789, 'f')) # ⼩小数点计数法. 保留留6位⼩小数
    print(format(1.23456789, '0.2f')) # ⼩小数点计数法. 保留留2位⼩小数
    print(format(1.23456789, '0.10f')) # ⼩小数点计数法. 保留留10位⼩小数
    print(format(1.23456789e+10000, 'F')) # ⼩小数点计数法.
    
  • 相关阅读:
    查看网站上保存的密码
    前端图片预览
    Amaze UI的一点总结
    简单实现图片验证码
    获取网页数据的例子
    谈谈网页中的ajax
    网页小技巧-360doc个人图书馆复制文字
    Js中的4个事件
    网页页面蒙版实现
    Spring+SprinMVC配置学习总结
  • 原文地址:https://www.cnblogs.com/fan-gx/p/12812228.html
Copyright © 2011-2022 走看看