博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lock_sh 示例_带有示例的Python date __str __()方法
阅读量:2528 次
发布时间:2019-05-11

本文共 1459 字,大约阅读时间需要 4 分钟。

lock_sh 示例

Python date .__ str __()方法 (Python date.__str__() Method)

date.__str__() method is used to manipulate objects of date class of module datetime.

date .__ str __()方法用于操作模块datetime的date类的对象。

It uses a date class object and returns a string representation of the object. For a date object d, str(d) is equivalent to d.isoformat(). str() is an instance method as it uses an instance of the class.

它使用日期类对象,并返回该对象的字符串表示形式。 对于日期对象d , str(d)等效于d.isoformat() 。 str()是一个实例方法,因为它使用类的实例。

Module:

模块:

import datetime

Class:

类:

from datetime import date

Syntax:

句法:

str()

Return value:

返回值:

The return type of this method is a string representing the original date.

此方法的返回类型是代表原始日期的字符串。

Example:

例:

## importing date classfrom datetime import date## Creating an instancex = date.today()d = str(x)print("Original object:",x)print("Date String:", d)print()## str function also uses the ISO formatx = date(2020,10,1)print("Date string of date 2020/10/1:", str(x))print()## str(x) is equivalent to x.isoformat() functionx = date(200,10,12)print("Date 200/10/12 in ISO 8601 format using isoformat() function:", x.isoformat())print("Date string 200/10/12  using str() function:", str(x))print( x.isoformat() == str(x))

Output

输出量

Original object: 2020-04-29Date String: 2020-04-29Date string of date 2020/10/1: 2020-10-01Date 200/10/12 in ISO 8601 format using isoformat() function: 0200-10-12Date string 200/10/12  using str() function: 0200-10-12True

翻译自:

lock_sh 示例

转载地址:http://chxzd.baihongyu.com/

你可能感兴趣的文章
局域网访问PHP项目网站 用IP地址进入
查看>>
VM虚拟机,Linux系统安装tools过程遇到 what is the location of the “ifconfig” program
查看>>
Jquery实现循环删除Reaper某一行
查看>>
脚本升级openssh
查看>>
linux学习(3)——vim文本编辑工具
查看>>
快速开发平台如何应用
查看>>
hadoop的理解
查看>>
Java测试当前应用所占用的内存示例
查看>>
网站限制IP访问应该怎么办
查看>>
121. Best Time to Buy and Sell Stock
查看>>
hdu 1005 根据递推公式构造矩阵 ( 矩阵快速幂)
查看>>
安装php扩展
查看>>
mysql统计某一个数据库中有几张表
查看>>
百度移动搜索主要有如下几类结果构成
查看>>
梦断代码最后4章读后感
查看>>
python学习---字符串
查看>>
Python爬虫面试题170道:2019版【1】
查看>>
JavaBean规范
查看>>
第四阶段 15_Linux tomcat安装与配置
查看>>
NAS 创建大文件
查看>>