兼职网站平台有哪些,做网站还需要兼容ie8吗,临汾网站建设销售,wordpress 3.7#x1f308;个人主页: Aileen_0v0 #x1f525;热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法 #x1f4ab;个人格言:“没有罗马,那就自己创造罗马~” #mermaid-svg-6gfBeOb6YRf7C52d {font-family:trebuchet ms,verdana,arial,sans-serif;font-siz…
个人主页: Aileen_0v0 热门专栏: 华为鸿蒙系统学习|计算机网络|数据结构与算法 个人格言:“没有罗马,那就自己创造罗马~” #mermaid-svg-6gfBeOb6YRf7C52d {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .error-icon{fill:#552222;}#mermaid-svg-6gfBeOb6YRf7C52d .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-6gfBeOb6YRf7C52d .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-6gfBeOb6YRf7C52d .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-6gfBeOb6YRf7C52d .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-6gfBeOb6YRf7C52d .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-6gfBeOb6YRf7C52d .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-6gfBeOb6YRf7C52d .marker{fill:#333333;stroke:#333333;}#mermaid-svg-6gfBeOb6YRf7C52d .marker.cross{stroke:#333333;}#mermaid-svg-6gfBeOb6YRf7C52d svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-6gfBeOb6YRf7C52d .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .cluster-label text{fill:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .cluster-label span{color:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .label text,#mermaid-svg-6gfBeOb6YRf7C52d span{fill:#333;color:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .node rect,#mermaid-svg-6gfBeOb6YRf7C52d .node circle,#mermaid-svg-6gfBeOb6YRf7C52d .node ellipse,#mermaid-svg-6gfBeOb6YRf7C52d .node polygon,#mermaid-svg-6gfBeOb6YRf7C52d .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-6gfBeOb6YRf7C52d .node .label{text-align:center;}#mermaid-svg-6gfBeOb6YRf7C52d .node.clickable{cursor:pointer;}#mermaid-svg-6gfBeOb6YRf7C52d .arrowheadPath{fill:#333333;}#mermaid-svg-6gfBeOb6YRf7C52d .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-6gfBeOb6YRf7C52d .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-6gfBeOb6YRf7C52d .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-6gfBeOb6YRf7C52d .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-6gfBeOb6YRf7C52d .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-6gfBeOb6YRf7C52d .cluster text{fill:#333;}#mermaid-svg-6gfBeOb6YRf7C52d .cluster span{color:#333;}#mermaid-svg-6gfBeOb6YRf7C52d div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-6gfBeOb6YRf7C52d :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Always seek out the seed of triumph inevery adversity. 文章目录 应用一应用二 #mermaid-svg-eochvdFtDyOjsuUs {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-eochvdFtDyOjsuUs .error-icon{fill:#552222;}#mermaid-svg-eochvdFtDyOjsuUs .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-eochvdFtDyOjsuUs .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-eochvdFtDyOjsuUs .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-eochvdFtDyOjsuUs .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-eochvdFtDyOjsuUs .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-eochvdFtDyOjsuUs .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-eochvdFtDyOjsuUs .marker{fill:#333333;stroke:#333333;}#mermaid-svg-eochvdFtDyOjsuUs .marker.cross{stroke:#333333;}#mermaid-svg-eochvdFtDyOjsuUs svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-eochvdFtDyOjsuUs .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-eochvdFtDyOjsuUs .cluster-label text{fill:#333;}#mermaid-svg-eochvdFtDyOjsuUs .cluster-label span{color:#333;}#mermaid-svg-eochvdFtDyOjsuUs .label text,#mermaid-svg-eochvdFtDyOjsuUs span{fill:#333;color:#333;}#mermaid-svg-eochvdFtDyOjsuUs .node rect,#mermaid-svg-eochvdFtDyOjsuUs .node circle,#mermaid-svg-eochvdFtDyOjsuUs .node ellipse,#mermaid-svg-eochvdFtDyOjsuUs .node polygon,#mermaid-svg-eochvdFtDyOjsuUs .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-eochvdFtDyOjsuUs .node .label{text-align:center;}#mermaid-svg-eochvdFtDyOjsuUs .node.clickable{cursor:pointer;}#mermaid-svg-eochvdFtDyOjsuUs .arrowheadPath{fill:#333333;}#mermaid-svg-eochvdFtDyOjsuUs .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-eochvdFtDyOjsuUs .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-eochvdFtDyOjsuUs .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-eochvdFtDyOjsuUs .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-eochvdFtDyOjsuUs .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-eochvdFtDyOjsuUs .cluster text{fill:#333;}#mermaid-svg-eochvdFtDyOjsuUs .cluster span{color:#333;}#mermaid-svg-eochvdFtDyOjsuUs div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-eochvdFtDyOjsuUs :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Python标准库 友情链接点击带颜色字体即可跳转 Python标准库链接 Python标准库datetime模块包含用于日期date和时间time的数据类型。 Python的datetime模块提供了处理日期和时间的功能。它包含了多个类和函数可以用来创建、操作、格式化和计算日期和时间。
datetime模块 下面是一些datetime模块的常用类和函数以及它们的使用场景
1.datetime类用来表示日期和时间的类。可以创建一个datetime对象然后对其进行各种操作比如获取日期、时间、年、月、日等。
import datetime# 创建一个datetime对象
now datetime.datetime.now()# 获取日期和时间
print(now)# 获取年、月、日、时、分、秒等
print(now.year)
print(now.month)
print(now.day)
print(now.hour)
print(now.minute)
print(now.second)2.timedelta类用来表示时间间隔的类。可以进行日期和时间的加减操作计算两个日期之间的时间间隔等。
import datetime# 创建一个timedelta对象表示两天的时间间隔
delta datetime.timedelta(days2)# 获取当前日期
now datetime.datetime.now()# 计算两天后的日期
future_date now deltaprint(future_date)3. strftime()函数用来将日期和时间格式化为字符串。可以使用各种格式化指令来指定输出的格式。
import datetime# 获取当前日期和时间
now datetime.datetime.now()# 将日期和时间格式化为字符串
formatted now.strftime(%Y-%m-%d %H:%M:%S)print(formatted)4. strptime()函数用来将字符串解析为datetime对象。可以使用与strftime()函数相同的格式化指令来解析字符串。
import datetime# 将字符串解析为datetime对象
date_str 2022-01-01
date datetime.datetime.strptime(date_str, %Y-%m-%d)print(date)datetime模块的使用场景包括但不限于以下几个方面
处理日期和时间的计算可以通过datetime类和timedelta类来进行日期和时间的计算比如计算两个日期之间的时间间隔、计算某个日期的前后几天等。时间格式化可以使用strftime()函数将日期和时间格式化为特定的字符串格式比如将日期和时间格式化为yyyy-mm-dd或hh:mm:ss等。字符串解析为日期和时间可以使用strptime()函数将字符串解析为datetime对象便于进行日期和时间的处理和计算。 #mermaid-svg-unxrMWVp5Mti8EQh {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .error-icon{fill:#552222;}#mermaid-svg-unxrMWVp5Mti8EQh .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-unxrMWVp5Mti8EQh .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-unxrMWVp5Mti8EQh .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-unxrMWVp5Mti8EQh .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-unxrMWVp5Mti8EQh .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-unxrMWVp5Mti8EQh .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-unxrMWVp5Mti8EQh .marker{fill:#333333;stroke:#333333;}#mermaid-svg-unxrMWVp5Mti8EQh .marker.cross{stroke:#333333;}#mermaid-svg-unxrMWVp5Mti8EQh svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-unxrMWVp5Mti8EQh .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .cluster-label text{fill:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .cluster-label span{color:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .label text,#mermaid-svg-unxrMWVp5Mti8EQh span{fill:#333;color:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .node rect,#mermaid-svg-unxrMWVp5Mti8EQh .node circle,#mermaid-svg-unxrMWVp5Mti8EQh .node ellipse,#mermaid-svg-unxrMWVp5Mti8EQh .node polygon,#mermaid-svg-unxrMWVp5Mti8EQh .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-unxrMWVp5Mti8EQh .node .label{text-align:center;}#mermaid-svg-unxrMWVp5Mti8EQh .node.clickable{cursor:pointer;}#mermaid-svg-unxrMWVp5Mti8EQh .arrowheadPath{fill:#333333;}#mermaid-svg-unxrMWVp5Mti8EQh .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-unxrMWVp5Mti8EQh .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-unxrMWVp5Mti8EQh .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-unxrMWVp5Mti8EQh .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-unxrMWVp5Mti8EQh .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-unxrMWVp5Mti8EQh .cluster text{fill:#333;}#mermaid-svg-unxrMWVp5Mti8EQh .cluster span{color:#333;}#mermaid-svg-unxrMWVp5Mti8EQh div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-unxrMWVp5Mti8EQh :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} datetime的应用 应用一
根据加入时间计算出自己加入CSDN的天数 #mermaid-svg-uYGeNABk2PjG3N8X {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .error-icon{fill:#552222;}#mermaid-svg-uYGeNABk2PjG3N8X .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-uYGeNABk2PjG3N8X .edge-thickness-normal{stroke-width:2px;}#mermaid-svg-uYGeNABk2PjG3N8X .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-uYGeNABk2PjG3N8X .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-uYGeNABk2PjG3N8X .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-uYGeNABk2PjG3N8X .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-uYGeNABk2PjG3N8X .marker{fill:#333333;stroke:#333333;}#mermaid-svg-uYGeNABk2PjG3N8X .marker.cross{stroke:#333333;}#mermaid-svg-uYGeNABk2PjG3N8X svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-uYGeNABk2PjG3N8X .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .cluster-label text{fill:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .cluster-label span{color:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .label text,#mermaid-svg-uYGeNABk2PjG3N8X span{fill:#333;color:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .node rect,#mermaid-svg-uYGeNABk2PjG3N8X .node circle,#mermaid-svg-uYGeNABk2PjG3N8X .node ellipse,#mermaid-svg-uYGeNABk2PjG3N8X .node polygon,#mermaid-svg-uYGeNABk2PjG3N8X .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-uYGeNABk2PjG3N8X .node .label{text-align:center;}#mermaid-svg-uYGeNABk2PjG3N8X .node.clickable{cursor:pointer;}#mermaid-svg-uYGeNABk2PjG3N8X .arrowheadPath{fill:#333333;}#mermaid-svg-uYGeNABk2PjG3N8X .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-uYGeNABk2PjG3N8X .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-uYGeNABk2PjG3N8X .edgeLabel{background-color:#e8e8e8;text-align:center;}#mermaid-svg-uYGeNABk2PjG3N8X .edgeLabel rect{opacity:0.5;background-color:#e8e8e8;fill:#e8e8e8;}#mermaid-svg-uYGeNABk2PjG3N8X .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-uYGeNABk2PjG3N8X .cluster text{fill:#333;}#mermaid-svg-uYGeNABk2PjG3N8X .cluster span{color:#333;}#mermaid-svg-uYGeNABk2PjG3N8X div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-uYGeNABk2PjG3N8X :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;}#mermaid-svg-uYGeNABk2PjG3N8X .someclass*{fill:#f96!important;}#mermaid-svg-uYGeNABk2PjG3N8X .someclass span{fill:#f96!important;} 解题步骤 1.根据日期构造出datetime类型的变量 2.把两个变量进行相减得到结果即为所求 #先构造 datetime 变量
from datetime import datetime as ts
date1 ts(year 2024, month 1, day 16)
date2 ts(year 2023, month 3, day 14)
print(date1 - date2)应用二
输入2023年的一个日期输出星期几
写法1
import datetime
date_str input(输入日期格式YYYY-MM-DD:)
year,month,day map(int,date_str.split(-))
date1 datetime.date(year,month,day)
weekday date1.strftime(%A)
print(这个日期是星期,weekday)写法2
from datetime import date
date_str input(输入日期格式YYYY-MM-DD:)
year,month,day map(int,date_str.split(-))
date2 datetime.date(year,month,day)
weekday date2.strftime(%A)
print(这个日期是星期,weekday)从上面的代码我们可以看出datetime这个大模块里面包含了日期【date】和时间【time】模块在这里我们就列举了常用的如果小伙伴对它的其它模块用法感兴趣可以点击Python官方文件夹进行深入学习。