【问题标题】:Python: How to print date format with using the help function?Python:如何使用帮助功能打印日期格式?
【发布时间】:2022-01-19 17:54:26
【问题描述】:

我想打印日期格式,所以每次我想打印日期时都不需要在导航器中搜索,如下代码所示:

time = now.strftime("%Y-%m-%d %H:%M:%S")
print("time:", time)

我一直在搜索,但没有找到任何关于此的内容。

当您运行help(the_date.strftime) 时,它不会显示可能的参数。

【问题讨论】:

  • ..dont need to search in the navigator.. - 添加指向您的浏览器收藏夹的链接 - https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior

标签: python python-3.x printing parameters strftime


【解决方案1】:

您可以在此处查看格式代码 - Basic date and time types

【讨论】:

    【解决方案2】:

    以下示例参考:

         import time
        print("time:{}".format(time.strftime('%Y-%m-%d %H:%M:%S')))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-14
      • 2014-02-15
      • 1970-01-01
      相关资源
      最近更新 更多