Hello, Hello, my name is Dream ah , An interesting Python Blogger , Please go easy on me
2021 Blog star of the year TOP100,2021 Blog star of the year TOP5,Python Quality creators in the field , Welcome to cooperate with me ( At the end of the article VX Want to join the learning exchange group or Learning materials welcome +++)Introductory notes : This paradise never lacks genius , Hard work is your final ticket !
Last , May we all shine where we can't see , Let's make progress together
“ Ten thousand times sad , There will still be Dream, I've been waiting for you in the warmest place ”, It's me ! Ha ha ha ~
Preface :
【Python Training camp 】 Is aimed at Python A war created by language learning Brush questions and revel party! If you don't grasp the solid foundation of knowledge , Welcome to this course :Python Public class It's best to use it together ~ If you like, hurry up and subscribe ! If you don't have self-control or motivation to learn and communicate together , Welcome to send a private letter or add my... At the end of the text VX, I will pull you into the learning exchange group , Let's exchange and study together , Group punch in
Title Description
This question is to fill in the blanks , Just calculate the result , Use the output statement in the code to output the filled results .
Whole 2020 century (19011901 year 11 month 11 solstice 20002000 year 1212 month 3131 Between days ), How many Mondays are there in all ?( Don't tell me you don't know what day it is today )
Operation limit
Maximum operation time :1s
Maximum running memory : 128M
start = date(1901, 1, 1) -end = date(2001, 1, 1)
start += temp
# Time : 2022/2/13 22:56
# File : Monday .py
# Author : yes Dream ah !
# VX : Xu18300396393
# Ten thousand times sad , There will still be Dream, I've been waiting for you in the warmest place !
from datetime import *
start = date(1901, 1, 1) # 1901-01-01
# print(start)
end = date(2001, 1, 1)
temp = timedelta(days=1)
n = 0
while start != end:
if start.weekday() == 0:
n += 1
start += temp
print(n)
datetime Some uses of the module are as follows :
from datetime import datetime
from datetime import timedelta
import time
# 1) Get the current date and time
now_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # At this time, the time is month, day, hour, minute and second
now_time = time.strftime("%Y-%m-%d %H:%M:%S") # At this time, the time is
today = datetime.today() # When returning the current time, every minute and second is 0
print(" current time ")
print(today)
today1 = datetime.now() # Returns the current date and time
now.hour # when
now.minute # branch
now.isoweekday()# Back to 1-7 On behalf of the Monday -- Sunday ;
now.weekday()# Back to 0-6 On behalf of the Monday -- By Sunday
# The standard format is %w 1-6 It means Monday -- Saturday ,0 On behalf of the Sunday
print( today1 )
today2 = datetime.utcnow() # The time to return to the current Dongba district is less than that at that time 8 Hours
print(today2)
# 2) Get the specified date and time , Add and subtract
time= datetime(2019, 5, 12, 12, 13, 14)
d= time + timedelta(weeks=0, days=0, hours=0, minutes=0, seconds=0, milliseconds=0, microseconds=0, )
# In turn " Zhou " " God ", " when "," branch "," second "," millisecond "," Microsecond "
print(time)
print(d)
time1= "2019-5-12 12:13:14" # character string date
d1 = datetime.strptime(str(time1),'%Y-%m-%d %H:%M:%S')
plus= d1 + timedelta(days=1) # Add
minus = d1 - timedelta(days=1) # reduce
print(time1)
print(d1)
print(plus)
print(minus )
time2= 20190512121314
d2 = datetime.strptime(str(time2),'%Y%m%d%H%M%S')
delta = d2 + timedelta(days=1)
print(time2)
print(d2 )
print(delta)
# 3) date datetime-timestamp Timestamps are transferred to each other
now_stamp = time.timestamp()
print(' Specify the time corresponding to the timestamp :', now_stamp)
print(' Corresponding to local time :', datetime.fromtimestamp(now_stamp ))
print('UTC Standard time :', datetime.utcfromtimestamp(now_stamp ))
print(' What day of the week :', datetime.fromtimestamp(now_stamp ).weekday())
# 4) datetime Time Convert to str character string
now = datetime.now()
print(' current time :', now)
print(now.strftime('%Y%m%d%H%M%S'))
Today is my day Python The first of the training camp 20 God , I hope to see the best of you every day
[Python Public class ] Zero base play Python The basic chapter ---- Section 1 :Python The introduction of
[Python Public class ] Zero base play Python Advanced ---- Section 1 :Python File operations in
Come on, let's have a problem swiping Carnival party Well !----【Python Training camp 】
All right. , That's all I want to share with you today
️️️ If you like , Don't be stingy with your one key triple connection ~