zoukankan      html  css  js  c++  java
  • Python数值日期时间笔记

    数值:

           格式化

          小数位的处理

    随机数:

          random.choice() 序列中随机选择一个值

          random.sample() 获取指定数目的序列

          random.shuffle() 打乱顺序

          random.randint() 生成范围内的随机整数

          random.random() 生成随机浮点数

          random.getrandbits() 生成指定bit位数的随机数

    日期时间:

        datetime   date, time, datetime

            datetime(year, month, day, …)

         格式转换:

                字符串到日期时间  datetime.datetime.strptime('txt','格式')

                日期时间到字符串  datetime.datetime.strftime('格式')

               占位符:

                     %Y   四位年份

                     %y  二位年份

                     %m  二位月份

                      %d  二位日期

                     %H  二位小时

                    %M  二位分钟

                    %S  二位秒数

                     %f  微妙

                     %  星期数, 0...

                     …

         时间差 timedelta:

               days

               hours

               seconds

  • 相关阅读:
    FILE
    基础知识const/typedef/函数指针/回调函数
    strchr
    ftell
    rewind
    fread
    poj 2309BST解题报告
    hdoj 4004The Frog's Games解题报告
    哈理工oj 1353LCM与数对解题报告
    poj 2453An Easy Problem解题报告
  • 原文地址:https://www.cnblogs.com/yang901112/p/11337040.html
Copyright © 2011-2022 走看看