zoukankan      html  css  js  c++  java
  • 1211诗词时空背景

    诗词时空背景

    来源

    根据目前的诗词,找出其创作时间,根据创作时间找出相近的诗词创作,提取诗词的背景信息以及对应的诗句,将该诗词创作的前后时间补充完整

    def get_poemtime_about_poem():
        poem_name = request.form.get("poem_name")
        db=MySqLHelper()
        desty = ['tang', 'song', 'yuan', 'ming', 'qing']
        author=''
        bg_time=''
        for it in desty:
            sql = "select * from " + it + " where title = '" + poem_name + "';"
            ret = db.selectone(sql=sql)
            if ret!=None:
                author=ret[2]
                bg_time=str(ret[9]).replace('','')
                break
        # print(author)
        # print(bg_time)
        date_list=[]
        back_list=[]
        poem_list=[]
        content_list=[]
        left=int(bg_time)-3
        right=int(bg_time)+3
        for it in desty:
            sql = "select * from " + it + " where author = '" + author + "';"
            ret,count = db.selectall(sql=sql)
            if ret!=None:
                for row in ret:
                    if str(row[9])!='' and str(row[9]).find('')==-1 and str(row[9]).find('')==-1 and str(row[6])!='':
                        time=int(str(row[9]).replace('',''))
                        if time>=left and time<=right and bool(re.search(r'\d', row[6])):
                            date_list.append(time)
                            back_list.append(row[6])
                            poem_list.append(row[0])
                            content_list.append(row[3])
        jsonData=[]
        for dd in range(left,right+1):
            for i in range(len(date_list)):
                time=date_list[i]
                poem=poem_list[i]
                back=back_list[i]
                content=content_list[i].replace('\n','').split('')
                ans_content=[]
                for it in content:
                    if it!='':
                        ans_content.append(it+"")
                if time==dd:
                    dic={}
                    dic['time']=str(time)+""
                    dic['title']=poem
                    dic['back']=back
                    dic['content']=ans_content
                    jsonData.append(dic)
        #print(json.dumps(jsonData).encode('utf-8').decode("unicode-escape"))
        return json.dumps(jsonData)

    效果

     

  • 相关阅读:
    WWDC2014苹果的“软件”发布会
    那些好用的iOS开发工具
    40个国人iOS技术博客
    深度解析开发项目之 05
    深度解析开发项目之 04
    深度解析开发项目之 03
    深度解析开发项目之 02
    成长为 iOS 大 V 的秘密
    理解 iOS 的内存管理
    峰回路转的提权08r2服务器
  • 原文地址:https://www.cnblogs.com/xiaofengzai/p/15677370.html
Copyright © 2011-2022 走看看