答:
1.
(1)CMD命令行下使用pydoc命令
(2)在python交互解释器中使用help()查看
(3)在python交互的解释器下导入sys模块查看
(4)命令行下使用pip查看
(5)使用yolk来查看
"""
Input file
language = ['PHP', 'PHP', 'Python', 'PHP', 'Python', 'JS', 'Python', 'Python','PHP', 'Python']
Output file
Python
"""
def most_element(language):
""" Return a list of lines after inserting a word in a specific line. """
from collections import Counter
c=Counter(language)
print(max(c.keys()))
答:
1.
from datetime import datetime, timezone, timedelta
def to_timestamp(dt_str, tz_str):
input_dt = datetime.strptime(dt_str, '%Y-%m-%d %H:%M:%S')
time_zone_num = re.match(r'UTC([+|-][\d]{1,2}):00', tz_str).group(1)
time_zone = timezone(timedelta(hours=int(time_zone_num)))
input_dt_tz = input_dt.replace(tzinfo=time_zone)
return input_dt_tz.timestamp()on
import datetime
import time
import calendar
def all_sundays(year):
#全年所有日期
cal = calendar.Calendar()
alldaylist = []
for month in list(range(1,13)):
listday = []
#调用calendar类的itermonthdays()方法,返回一个迭代器,含有指定年月的日子
for day in cal.itermonthdays(year,month):
#过滤迭代器中用于填充首尾的0
if day != 0:
listday.append(day)
alldaylist.append(listday)
#print(alldaylist)
for month in range(1,13):
for day in alldaylist[month-1]:
date=datetime.date(year,month,day)
#获取指定周日日期
weekday=datetime.datetime.isoweekday(date)
if weekday==7:
print(date)
all_sundays(2020)