lock_sh 示例_带有示例的Python date __str __()方法
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 class
from datetime import date
## Creating an instance
x = date.today()
d = str(x)
print("Original object:",x)
print("Date String:", d)
print()
## str function also uses the ISO format
x = date(2020,10,1)
print("Date string of date 2020/10/1:", str(x))
print()
## str(x) is equivalent to x.isoformat() function
x = 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-29
Date String: 2020-04-29
Date string of date 2020/10/1: 2020-10-01
Date 200/10/12 in ISO 8601 format using isoformat() function: 0200-10-12
Date string 200/10/12 using str() function: 0200-10-12
True
翻译自: https://www.includehelp.com/python/date-__str__-method-with-example.aspx
lock_sh 示例
lock_sh 示例_带有示例的Python date __str __()方法相关推荐
- python 示例_带有示例的Python date timetuple()方法
python 示例 Python date.timetuple()方法 (Python date.timetuple() Method) date.timetuple() method is used ...
- python 示例_带有示例的Python date isocalendar()方法
python 示例 Python date.isocalendar()方法 (Python date.isocalendar() Method) date.isocalendar() method i ...
- python示例_带有示例的Python功能指南
python示例 Python函数简介 (Introduction to Functions in Python) A function allows you to define a reusable ...
- python 示例_带有示例的Python File write()方法
python 示例 文件write()方法 (File write() Method) write() method is an inbuilt method in Python, it is use ...
- python 示例_带有示例的Python文件关闭属性
python 示例 文件关闭属性 (File closed Property) closed Property is an inbuilt property of File object (IO ob ...
- python 示例_带有示例的Python字典update()方法
python 示例 字典update()方法 (Dictionary update() Method) update() method is used to update the dictionary ...
- python 示例_带有示例的Python字典popitem()方法
python 示例 字典popitem()方法 (Dictionary popitem() Method) popitem() method is used to remove random/last ...
- python 示例_带有示例的Python File close()方法
python 示例 文件close()方法 (File close() Method) close() method is an inbuilt method in Python, it is use ...
- python 示例_带有示例的Python列表remove()方法
python 示例 列出remove()方法 (List remove() Method) remove() method is used to remove the first occurrence ...
最新文章
- python学习笔记——Thread常用方法
- idea mysql 创建表_idea 根据数据库表自动创建持久化类
- cocos2dx中关于Action动作的相关API的具体介绍
- 13.相机和图像——聚焦于对象实战,不断变化的焦距,景深_3
- Godaddy域名解锁、获取转移码(Authorization Code)及转出注意事项
- numpy矩阵乘法_NumPy矩阵乘法
- 使用 Python 和 Flask 实现 RESTful services
- 使用Mac电脑内置的屏幕共享功能,进行远程桌面管理
- java path combine_Path.Combine (合并两个路径字符串)方法的一些使用细节
- 仿Google+相册的动画
- 欧式空间与希尔伯特空间
- [转载]在安装win7系统时如何不产生100M的系统保留分区
- 主力用计算机吸筹,通达信主力吸筹指标
- 用python画钢铁侠_秒变钢铁侠,这个暑假,用 Python 让自己成为超级英雄!
- 如何制定项目PMO战略计划?
- Poi导入excel(合并单元格)
- VB对IE浏览器完全控制
- 过年不让放炮,我用Python实现了1000响大地红的特效
- VirtualBox 安装虚拟机步骤
- 阿里巴巴400集python教程_摆摊吧,程序员!阿里巴巴力荐Python400集视频
热门文章
- CSRF的绕过与利用
- 计算机考研379分,考研379分报考南开大学被刷,是调剂还是二战?师姐建议非常肯定...
- 以太网例程_开关量转以太网的应用
- 语句 查询每个人每个科目的最高分_转行数据分析师专栏(SQL篇)-05多表查询...
- CSS基础语法(三) CSS的6种特性
- AngularJS快速入门指南03:表达式
- JQuery让input从disabled变成enabled
- jQuery数据转换与提交
- 复习HTML CSS(2)
- JQuery DataTables Selected Row