import json
import urllib.request
import time
import datetime
date = time.strftime('%Y-%m-%d',time.localtime())
server_url = "http://timor.tech/api/holiday/info/"
vop_url_request = urllib.request.Request(server_url + date)
vop_response = urllib.request.urlopen(vop_url_request)
vop_data = json.loads(vop_response.read())
data1 = str(vop_data['holiday'])
if data1 == 'None':
data = datetime.datetime.today().weekday()
if str(data) == '5':
print("休息日")
elif str(data) == '6':
print("休息日")
else:
print("工作日")
else:
data = str(vop_data['holiday']['holiday'])
if data == 'False':
print("工作日")
elif data == 'True':
print('休息日')
else:
print('错误')
😆好的好的。
已经替你编辑,不错的帖子,注意:
学会编辑代码