问题:使用开发微信公众号时,使用客服接口发送链接消息,总是出链接代码
解决:引号错误引起的
方法:
url = "https://api.weixin.qq.com/cgi-bin/message/custom/send"
headers = {'content-type': 'charset=utf8'}
data = {
"touser":"OPENID",
"msgtype":"text",
"text":
{
"content":'Hello World 小蛮兔'
}
}
注意:链接中href一定是双引号,外面一定是单引号
参考:https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421140547
分类 "Web" 下的文章
问题:doc文档,ppt如何在线,在浏览器中浏览
解决:使用微软的链接
方法:
ppt在线浏览:
https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fbuild%2f2011%2fslides%2fTOOL-532T_Sutter.pptx
doc在线浏览
https://view.officeapps.live.com/op/view.aspx?src=newteach.pbworks.com%2Ff%2Fele%2Bnewsletter.docx
xlsx
https://view.officeapps.live.com/op/view.aspx?src=http%3A%2F%2Flearn.bankofamerica.com%2Fcontent%2Fexcel%2FWedding_Budget_Planner_Spreadsheet.xlsx
参考:https://blogs.office.com/en-us/2013/04/10/office-web-viewer-view-office-documents-in-a-browser/
问题:如何根据出生日期判断用户年龄?
解决:使用timedelta计算天数
方法:
# 根据生日计算用户年龄
def user_age(borndate):
today = datetime.date.today()
year = today.year
born_year = borndate.year
# 计算出生当年错过了多少天
born_first_day = borndate.replace(month=1, day=1)
born_diff = (borndate - born_first_day).days
year_first_day = today.replace(month=1, day=1)
today_diff = (today - year_first_day).days
if today_diff > born_diff:
return year - born_year
else:
return year - born_year - 1
问题:typecho分类列表,如何对当前分类增加active样式?
解决:使用$categorys->slug
方法:
<ul class="navbar-nav mr-auto">
<li class="nav-item<?php if($this->is('index')):?> current<?php endif;?>">
<a class="nav-link" href="<?php $this->options->siteUrl(); ?>">
<span><?php _e('首页'); ?></span></a>
</li>
<?php $this->widget('Widget_Metas_Category_List')->to($categorys); ?>