python爬虫 mysql数据库提示IntegrityError: (1062, "Duplicate entry 5C

背景:python scrapy框架,mysql(workbench数据库),不同的url设置为主键

根据报错内容,在数据库搜索重复的主键信息,数据库里并没有相关数据,重试,仍提示主键重复
请问这个是什么地方的问题?

1个回答

看下你的列是不是搞错了,比如把url插入到别的列上,而把其他列插入到主键上了
或者表、数据库、列搞错

Roinging
Roinging 你好,我第一次运行爬虫的时候是可以正常写入数据的,但是第二次运行爬虫的时候,有相应的去重操作,但是编译器报错主键重复的相关数据,数据库里确实是没有的
10 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
哪位大神帮忙解答一下爬虫返回信息{"code":"600","echo":"signature verification failed"}?
爬虫返回信息{"code":"600","echo":"signature verification failed"} 使用scrapy以及requests爬取手机APP应用时,返回的信息就是{"code":"600","echo":"signature verification failed"},请教大神帮忙解决。
python爬虫怎么获取伪元素(::after、::before)中的文本
# **python爬虫怎么获取伪元素(::after、::before)中的文本?比如如下代码:** ``` # <div id="alertDiv" role="alert" aria-live="rude" ng-bind-html="errorMessages" class="ng-binding">文本内容</div> ::after ``` # **我用的是selenium**
我有个str可以用eval函数转为dict,但是不能转为json,是什么原因??一直搞不懂是哪里出了问题
如下 ``` {"rateDetail":{"rateCount":{"total":47,"shop":0,"picNum":9,"used":1},"rateDanceInfo":{"storeType":4,"currentMilles":1578043709272,"showChooseTopic":false,"intervalMilles":25956873440},"rateList":[{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t3-18.png","rateDate":"2019-12-30 14:31:47","rateContent":"送来都是要自己手工加工的,好在不算复杂,公司布置,快递发货快","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071440421810,"aliMallSeller":false,"reply":"","pics":["//img.alicdn.com/bao/uploaded/i4/O1CN014Brfii1G2LxgkFswQ_!!0-rate.jpg"],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:DIY-25#座炮1个","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":30,"hours":10,"seconds":41,"month":11,"timezoneOffset":-480,"year":119,"minutes":34,"time":1577673281000,"day":1},"headExtraPic":"","aucNumId":0,"displayUserNick":"无***0","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":3,"gmtCreateTime":{"date":30,"hours":14,"seconds":47,"month":11,"timezoneOffset":-480,"year":119,"minutes":31,"time":1577687507000,"day":1},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-31 18:56:02","rateContent":"买了个大鞭炮颜色很正很喜庆,售后非常好,值得购买。","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071845394098,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:DIY-46#座炮1个","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":30,"hours":11,"seconds":17,"month":11,"timezoneOffset":-480,"year":119,"minutes":31,"time":1577676677000,"day":1},"headExtraPic":"","aucNumId":0,"displayUserNick":"t***7","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":31,"hours":18,"seconds":2,"month":11,"timezoneOffset":-480,"year":119,"minutes":56,"time":1577789762000,"day":2},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t2-18.png","rateDate":"2019-12-31 19:26:21","rateContent":"喜欢!质量不错!好看,喜庆","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071614365367,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:金元宝5个","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":31,"hours":19,"seconds":48,"month":11,"timezoneOffset":-480,"year":119,"minutes":25,"time":1577791548000,"day":2},"headExtraPic":"","aucNumId":0,"displayUserNick":"k***9","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":2,"gmtCreateTime":{"date":31,"hours":19,"seconds":21,"month":11,"timezoneOffset":-480,"year":119,"minutes":26,"time":1577791581000,"day":2},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t1-18.png","rateDate":"2019-12-30 15:49:11","rateContent":"绒布礼盒小了些,再大点就好了。","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071452993542,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:绒布-DIY新年礼盒","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":30,"hours":15,"seconds":12,"month":11,"timezoneOffset":-480,"year":119,"minutes":48,"time":1577692092000,"day":1},"headExtraPic":"","aucNumId":0,"displayUserNick":"杯***姐","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":1,"gmtCreateTime":{"date":30,"hours":15,"seconds":11,"month":11,"timezoneOffset":-480,"year":119,"minutes":49,"time":1577692151000,"day":1},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-30 10:14:15","rateContent":"不错,好看","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071876043121,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对35#","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":30,"hours":10,"seconds":56,"month":11,"timezoneOffset":-480,"year":119,"minutes":13,"time":1577672036000,"day":1},"headExtraPic":"","aucNumId":0,"displayUserNick":"t***3","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":30,"hours":10,"seconds":15,"month":11,"timezoneOffset":-480,"year":119,"minutes":14,"time":1577672055000,"day":1},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t2-18.png","rateDate":"2019-12-24 14:34:23","rateContent":"东西还不错,还会继续关注。祝店家生意兴隆。","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1070955990476,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个27#","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":24,"hours":14,"seconds":38,"month":11,"timezoneOffset":-480,"year":119,"minutes":33,"time":1577169218000,"day":2},"headExtraPic":"","aucNumId":0,"displayUserNick":"盲***苏","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":2,"gmtCreateTime":{"date":24,"hours":14,"seconds":23,"month":11,"timezoneOffset":-480,"year":119,"minutes":34,"time":1577169263000,"day":2},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-15 13:45:57","rateContent":"包装的很好没有挤压,特别喜庆,价格也很实惠,过年装饰特别有氛围","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1069303488800,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对46#","anony":true,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":15,"hours":13,"seconds":53,"month":11,"timezoneOffset":-480,"year":119,"minutes":44,"time":1576388693000,"day":0},"headExtraPic":"","aucNumId":0,"displayUserNick":"s***3","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":15,"hours":13,"seconds":57,"month":11,"timezoneOffset":-480,"year":119,"minutes":45,"time":1576388757000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t1-18.png","rateDate":"2019-12-27 19:52:36","rateContent":"习惯好评 喜庆","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071333802450,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:金座炮1对26#","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":27,"hours":19,"seconds":22,"month":11,"timezoneOffset":-480,"year":119,"minutes":52,"time":1577447542000,"day":5},"headExtraPic":"","aucNumId":0,"displayUserNick":"t***8","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":1,"gmtCreateTime":{"date":27,"hours":19,"seconds":36,"month":11,"timezoneOffset":-480,"year":119,"minutes":52,"time":1577447556000,"day":5},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-15 13:02:50","rateContent":"挺好的很喜庆","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1069516745214,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对35#发光","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":14,"hours":18,"seconds":30,"month":11,"timezoneOffset":-480,"year":119,"minutes":1,"time":1576317690000,"day":6},"headExtraPic":"","aucNumId":0,"displayUserNick":"如***c","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":15,"hours":13,"seconds":50,"month":11,"timezoneOffset":-480,"year":119,"minutes":2,"time":1576386170000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-28 19:53:38","rateContent":"盖子有些盖不住,老容易开","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071462398427,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:金元宝5个","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":28,"hours":15,"seconds":30,"month":11,"timezoneOffset":-480,"year":119,"minutes":43,"time":1577519010000,"day":6},"headExtraPic":"","aucNumId":0,"displayUserNick":"谈***1","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":28,"hours":19,"seconds":38,"month":11,"timezoneOffset":-480,"year":119,"minutes":53,"time":1577534018000,"day":6},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-10 08:39:50","rateContent":"好看!喜庆!","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1068964414165,"aliMallSeller":false,"reply":"","pics":["//img.alicdn.com/bao/uploaded/i4/O1CN01wG1pf21XMMjR6b7Mz_!!0-rate.jpg","//img.alicdn.com/bao/uploaded/i2/O1CN01xCkmU21XMMjVPYGEy_!!0-rate.jpg"],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对46#","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":10,"hours":8,"seconds":59,"month":11,"timezoneOffset":-480,"year":119,"minutes":38,"time":1575938339000,"day":2},"headExtraPic":"","aucNumId":0,"displayUserNick":"凯***鼠","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":10,"hours":8,"seconds":50,"month":11,"timezoneOffset":-480,"year":119,"minutes":39,"time":1575938390000,"day":2},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":{"videoList":[],"commentId":0,"days":1,"reply":"","commentTime":"2019-12-24 00:10:24","pics":[],"content":"掉金粉掉得厉害,手一拿都沾手上,哎~"},"fromMemory":0,"picsSmall":[],"tmallSweetPic":"tmall-grade-t4-18.png","rateDate":"2019-12-22 13:16:50","rateContent":"质量还可以,挺好看,但还是有一些掉金粉。","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1070955499593,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个27#","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":22,"hours":12,"seconds":42,"month":11,"timezoneOffset":-480,"year":119,"minutes":28,"time":1576988922000,"day":0},"headExtraPic":"","aucNumId":0,"displayUserNick":"m***9","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":4,"gmtCreateTime":{"date":22,"hours":13,"seconds":50,"month":11,"timezoneOffset":-480,"year":119,"minutes":16,"time":1576991810000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-22 22:41:55","rateContent":"买的和图片差远了,质量还不好","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1070786310037,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对26#发光","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":19,"hours":13,"seconds":22,"month":11,"timezoneOffset":-480,"year":119,"minutes":2,"time":1576731742000,"day":4},"headExtraPic":"","aucNumId":0,"displayUserNick":"z***7","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":22,"hours":22,"seconds":55,"month":11,"timezoneOffset":-480,"year":119,"minutes":41,"time":1577025715000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-06 19:35:43","rateContent":"看着很不错,卖家很有耐心服务态度特别好","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1068400873395,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个27#","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":6,"hours":19,"seconds":6,"month":11,"timezoneOffset":-480,"year":119,"minutes":35,"time":1575632106000,"day":5},"headExtraPic":"","aucNumId":0,"displayUserNick":"睿***9","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":6,"hours":19,"seconds":43,"month":11,"timezoneOffset":-480,"year":119,"minutes":35,"time":1575632143000,"day":5},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-12 20:42:21","rateContent":"宝贝收到了,质量非常好特别漂亮喜欢","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1068921768574,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个27#","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":12,"hours":20,"seconds":25,"month":11,"timezoneOffset":-480,"year":119,"minutes":41,"time":1576154485000,"day":4},"headExtraPic":"","aucNumId":0,"displayUserNick":"王***顺","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":12,"hours":20,"seconds":21,"month":11,"timezoneOffset":-480,"year":119,"minutes":42,"time":1576154541000,"day":4},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-15 00:33:33","rateContent":"要摆件选了很多个,这个比较满意,不错","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1069243836785,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:财神摆件3号55#","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":15,"hours":0,"seconds":37,"month":11,"timezoneOffset":-480,"year":119,"minutes":31,"time":1576341097000,"day":0},"headExtraPic":"","aucNumId":0,"displayUserNick":"肥***曰","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":15,"hours":0,"seconds":33,"month":11,"timezoneOffset":-480,"year":119,"minutes":33,"time":1576341213000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-07 21:11:11","rateContent":"东西超级好,卖家态度也好,快递也快喜欢","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1068295024297,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个27#","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":7,"hours":21,"seconds":19,"month":11,"timezoneOffset":-480,"year":119,"minutes":10,"time":1575724219000,"day":6},"headExtraPic":"","aucNumId":0,"displayUserNick":"t***7","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":7,"hours":21,"seconds":11,"month":11,"timezoneOffset":-480,"year":119,"minutes":11,"time":1575724271000,"day":6},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-12-05 14:09:31","rateContent":"东西很好,满意!","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1068468134560,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:烫金座炮1个35#","anony":false,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":4,"hours":16,"seconds":46,"month":11,"timezoneOffset":-480,"year":119,"minutes":5,"time":1575446746000,"day":3},"headExtraPic":"","aucNumId":0,"displayUserNick":"几***哇","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"111-11-0,1;","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":5,"hours":14,"seconds":31,"month":11,"timezoneOffset":-480,"year":119,"minutes":9,"time":1575526171000,"day":4},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2019-11-17 19:55:54","rateContent":"材质不是很好,太软了,安上以后容易开。","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1065771217365,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:大号元宝4个","anony":false,"displayUserNumId":0,"goldUser":true,"attributesMap":null,"tradeEndTime":{"date":17,"hours":19,"seconds":54,"month":10,"timezoneOffset":-480,"year":119,"minutes":49,"time":1573991394000,"day":0},"headExtraPic":"","aucNumId":0,"displayUserNick":"t***9","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":17,"hours":19,"seconds":54,"month":10,"timezoneOffset":-480,"year":119,"minutes":55,"time":1573991754000,"day":0},"useful":true,"displayUserRateLink":""},{"auctionPicUrl":"","userInfo":"","displayRatePic":"","dsr":0,"displayRateSum":0,"appendComment":null,"fromMemory":0,"picsSmall":[],"tmallSweetPic":"","rateDate":"2020-01-03 14:21:24","rateContent":"一般","fromMall":true,"userIdEncryption":"","sellerId":735980882,"videoList":[],"displayUserLink":"","id":1071725336425,"aliMallSeller":false,"reply":"","pics":[],"buyCount":0,"userVipLevel":0,"auctionSku":"颜色分类:鸿福座炮1对26#","anony":true,"displayUserNumId":0,"goldUser":false,"attributesMap":null,"tradeEndTime":{"date":1,"hours":16,"seconds":8,"month":0,"timezoneOffset":-480,"year":120,"minutes":24,"time":1577867048000,"day":3},"headExtraPic":"","aucNumId":0,"displayUserNick":"涓***姐","structuredRateList":[],"carServiceLocation":"","userVipPic":"","serviceRateContent":"","memberIcon":"","attributes":"","position":"","cmsSource":"天猫","tamllSweetLevel":0,"gmtCreateTime":{"date":3,"hours":14,"seconds":24,"month":0,"timezoneOffset":-480,"year":120,"minutes":21,"time":1578032484000,"day":5},"useful":true,"displayUserRateLink":""}],"searchinfo":"","from":"search","paginator":{"lastPage":3,"page":1,"items":41},"tags":[]}} ```
部署flask项目到heroku上时,出现psycopg2.errors.UndefinedTable: relation "question" does not exist问题,该怎么解决?
当我把flask项目部署到heroku上后,打开app时显示**Internal Server Error**. 报错为 ``` psycopg2.errors.UndefinedTable: relation "question" does not exist ``` 我google下,可能是由于migrations文件导致的,于是我就把该文件删掉了。但依然出现同样的问题。 求大神帮忙,现在踩在坑里有点出不去了。 这是我的config.py文件: ``` import os DEBUG = True SECRET_KEY = os.urandom(24) MAX_CONTENT_LENGTH = 1 * 1024 * 1024 SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') SQLALCHEMY_TRACK_MODIFICATIONS=False ``` 下面是heroku 的logs: ``` 2019-11-17T08:43:29.637889+00:00 app[web.1]: [2019-11-17 08:43:29 +0000] [11] [ERROR] Error handling request / 2019-11-17T08:43:29.637935+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:43:29.637940+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:43:29.637942+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:43:29.637945+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:43:29.637947+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:43:29.637949+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T08:43:29.637952+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:43:29.637955+00:00 app[web.1]: ^ 2019-11-17T08:43:29.637956+00:00 app[web.1]: 2019-11-17T08:43:29.637958+00:00 app[web.1]: 2019-11-17T08:43:29.637960+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T08:43:29.637962+00:00 app[web.1]: 2019-11-17T08:43:29.637964+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:43:29.637966+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T08:43:29.637968+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T08:43:29.637970+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T08:43:29.637972+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T08:43:29.637984+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T08:43:29.637986+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T08:43:29.637988+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T08:43:29.637990+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T08:43:29.637992+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T08:43:29.637993+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:43:29.637995+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:43:29.637997+00:00 app[web.1]: raise value 2019-11-17T08:43:29.637999+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T08:43:29.638000+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T08:43:29.638002+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T08:43:29.638004+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T08:43:29.638006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T08:43:29.638008+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:43:29.638010+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:43:29.638011+00:00 app[web.1]: raise value 2019-11-17T08:43:29.638013+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T08:43:29.638015+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T08:43:29.638017+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T08:43:29.638019+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T08:43:29.638021+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T08:43:29.638023+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T08:43:29.638025+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T08:43:29.638027+00:00 app[web.1]: return list(self) 2019-11-17T08:43:29.638029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T08:43:29.638031+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T08:43:29.638033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T08:43:29.638035+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T08:43:29.638037+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T08:43:29.638039+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T08:43:29.638041+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T08:43:29.638043+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T08:43:29.638045+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T08:43:29.638047+00:00 app[web.1]: distilled_params, 2019-11-17T08:43:29.638049+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T08:43:29.638051+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T08:43:29.638053+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T08:43:29.638055+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T08:43:29.638057+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T08:43:29.638059+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T08:43:29.638061+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T08:43:29.638063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T08:43:29.638076+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:43:29.638079+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:43:29.638081+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:43:29.638083+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:43:29.638085+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T08:43:29.638087+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:43:29.638089+00:00 app[web.1]: ^ 2019-11-17T08:43:29.638091+00:00 app[web.1]: 2019-11-17T08:43:29.638095+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T08:43:29.638097+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T08:43:29.638099+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T08:43:29.638285+00:00 app[web.1]: 10.61.164.89 - - [17/Nov/2019:08:43:29 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T08:44:42.918911+00:00 app[web.1]: [2019-11-17 08:44:42 +0000] [11] [ERROR] Error handling request / 2019-11-17T08:44:42.918940+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:44:42.918944+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:44:42.918946+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:44:42.918948+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:44:42.918950+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:44:42.918952+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T08:44:42.918955+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:44:42.918957+00:00 app[web.1]: ^ 2019-11-17T08:44:42.918959+00:00 app[web.1]: 2019-11-17T08:44:42.918961+00:00 app[web.1]: 2019-11-17T08:44:42.918963+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T08:44:42.918965+00:00 app[web.1]: 2019-11-17T08:44:42.918967+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T08:44:42.918969+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T08:44:42.918971+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T08:44:42.918973+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T08:44:42.918975+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T08:44:42.918977+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T08:44:42.918979+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T08:44:42.918981+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T08:44:42.918983+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T08:44:42.918985+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T08:44:42.918988+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:44:42.918989+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:44:42.918991+00:00 app[web.1]: raise value 2019-11-17T08:44:42.918994+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T08:44:42.918996+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T08:44:42.918998+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T08:44:42.919000+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T08:44:42.919002+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T08:44:42.919004+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T08:44:42.919006+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T08:44:42.919008+00:00 app[web.1]: raise value 2019-11-17T08:44:42.919010+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T08:44:42.919012+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T08:44:42.919014+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T08:44:42.919016+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T08:44:42.919018+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T08:44:42.919020+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T08:44:42.919022+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T08:44:42.919025+00:00 app[web.1]: return list(self) 2019-11-17T08:44:42.919027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T08:44:42.919028+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T08:44:42.919031+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T08:44:42.919033+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T08:44:42.919035+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T08:44:42.919037+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T08:44:42.919039+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T08:44:42.919041+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T08:44:42.919043+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T08:44:42.919046+00:00 app[web.1]: distilled_params, 2019-11-17T08:44:42.919048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T08:44:42.919050+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T08:44:42.919052+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T08:44:42.919054+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T08:44:42.919056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T08:44:42.919058+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T08:44:42.919060+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T08:44:42.919063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T08:44:42.919074+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T08:44:42.919077+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T08:44:42.919079+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T08:44:42.919081+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T08:44:42.919083+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T08:44:42.919085+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T08:44:42.919087+00:00 app[web.1]: ^ 2019-11-17T08:44:42.919088+00:00 app[web.1]: 2019-11-17T08:44:42.919091+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T08:44:42.919094+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T08:44:42.919096+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T08:44:42.919234+00:00 app[web.1]: 10.5.225.117 - - [17/Nov/2019:08:44:42 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T08:44:42.918749+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=c195162e-6529-4fb0-9aac-1d9dd9a450e8 fwd="58.182.174.147" dyno=web.1 connect=1ms service=7ms status=500 bytes=244 protocol=https 2019-11-17T09:02:25.748890+00:00 app[web.1]: [2019-11-17 09:02:25 +0000] [12] [ERROR] Error handling request / 2019-11-17T09:02:25.748917+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:02:25.748921+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:02:25.748923+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:02:25.748932+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:02:25.748934+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:02:25.748936+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T09:02:25.748939+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:02:25.748943+00:00 app[web.1]: ^ 2019-11-17T09:02:25.748944+00:00 app[web.1]: 2019-11-17T09:02:25.748947+00:00 app[web.1]: 2019-11-17T09:02:25.748949+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T09:02:25.748950+00:00 app[web.1]: 2019-11-17T09:02:25.748952+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:02:25.748953+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T09:02:25.748955+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T09:02:25.748956+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T09:02:25.748958+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T09:02:25.748991+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T09:02:25.748994+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T09:02:25.748996+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T09:02:25.748998+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T09:02:25.749000+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T09:02:25.749002+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:02:25.749004+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:02:25.749006+00:00 app[web.1]: raise value 2019-11-17T09:02:25.749008+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T09:02:25.749010+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T09:02:25.749012+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T09:02:25.749014+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T09:02:25.749016+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T09:02:25.749018+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:02:25.749020+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:02:25.749023+00:00 app[web.1]: raise value 2019-11-17T09:02:25.749024+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T09:02:25.749026+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T09:02:25.749027+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T09:02:25.749029+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T09:02:25.749030+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T09:02:25.749032+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T09:02:25.749033+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T09:02:25.749036+00:00 app[web.1]: return list(self) 2019-11-17T09:02:25.749038+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T09:02:25.749039+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T09:02:25.749041+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T09:02:25.749042+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T09:02:25.749044+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T09:02:25.749045+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T09:02:25.749047+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T09:02:25.749048+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T09:02:25.749050+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T09:02:25.749051+00:00 app[web.1]: distilled_params, 2019-11-17T09:02:25.749053+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T09:02:25.749054+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T09:02:25.749056+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T09:02:25.749057+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T09:02:25.749059+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T09:02:25.749060+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T09:02:25.749062+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T09:02:25.749063+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T09:02:25.749074+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:02:25.749076+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:02:25.749078+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:02:25.749080+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:02:25.749082+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T09:02:25.749084+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:02:25.749087+00:00 app[web.1]: ^ 2019-11-17T09:02:25.749089+00:00 app[web.1]: 2019-11-17T09:02:25.749092+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T09:02:25.749094+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] 2019-11-17T09:02:25.749096+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405) 2019-11-17T09:02:25.749271+00:00 app[web.1]: 10.69.244.94 - - [17/Nov/2019:09:02:25 +0000] "GET / HTTP/1.1" 500 0 "-" "-" 2019-11-17T09:02:25.755053+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=181975e4-7c78-4f7f-b131-4b1ddb544e02 fwd="58.182.174.147" dyno=web.1 connect=0ms service=92ms status=500 bytes=244 protocol=https 2019-11-17T09:06:00.663577+00:00 heroku[router]: at=info method=GET path="/" host=tianliang-flask-app.herokuapp.com request_id=571550f7-554b-42d0-b127-0a4837f6aae9 fwd="58.182.174.147" dyno=web.1 connect=1ms service=17ms status=500 bytes=244 protocol=https 2019-11-17T09:06:00.661593+00:00 app[web.1]: [2019-11-17 09:06:00 +0000] [11] [ERROR] Error handling request / 2019-11-17T09:06:00.661619+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:06:00.662439+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:06:00.662443+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:06:00.662447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:06:00.662449+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:06:00.662452+00:00 app[web.1]: psycopg2.errors.UndefinedTable: relation "question" does not exist 2019-11-17T09:06:00.662455+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:06:00.662457+00:00 app[web.1]: ^ 2019-11-17T09:06:00.662459+00:00 app[web.1]: 2019-11-17T09:06:00.662461+00:00 app[web.1]: 2019-11-17T09:06:00.662464+00:00 app[web.1]: The above exception was the direct cause of the following exception: 2019-11-17T09:06:00.662466+00:00 app[web.1]: 2019-11-17T09:06:00.662471+00:00 app[web.1]: Traceback (most recent call last): 2019-11-17T09:06:00.662473+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 134, in handle 2019-11-17T09:06:00.662476+00:00 app[web.1]: self.handle_request(listener, req, client, addr) 2019-11-17T09:06:00.662478+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/sync.py", line 175, in handle_request 2019-11-17T09:06:00.662480+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response) 2019-11-17T09:06:00.662483+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__ 2019-11-17T09:06:00.662486+00:00 app[web.1]: return self.wsgi_app(environ, start_response) 2019-11-17T09:06:00.662488+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app 2019-11-17T09:06:00.662491+00:00 app[web.1]: response = self.handle_exception(e) 2019-11-17T09:06:00.662493+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception 2019-11-17T09:06:00.662495+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:06:00.662498+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:06:00.662500+00:00 app[web.1]: raise value 2019-11-17T09:06:00.662502+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app 2019-11-17T09:06:00.662505+00:00 app[web.1]: response = self.full_dispatch_request() 2019-11-17T09:06:00.662507+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request 2019-11-17T09:06:00.662509+00:00 app[web.1]: rv = self.handle_user_exception(e) 2019-11-17T09:06:00.662511+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception 2019-11-17T09:06:00.662513+00:00 app[web.1]: reraise(exc_type, exc_value, tb) 2019-11-17T09:06:00.662515+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise 2019-11-17T09:06:00.662517+00:00 app[web.1]: raise value 2019-11-17T09:06:00.662519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request 2019-11-17T09:06:00.662521+00:00 app[web.1]: rv = self.dispatch_request() 2019-11-17T09:06:00.662523+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request 2019-11-17T09:06:00.662526+00:00 app[web.1]: return self.view_functions[rule.endpoint](**req.view_args) 2019-11-17T09:06:00.662528+00:00 app[web.1]: File "/app/project.py", line 27, in index 2019-11-17T09:06:00.662530+00:00 app[web.1]: 'questions': Questions.query.order_by(desc('create_time')).all() 2019-11-17T09:06:00.662532+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3186, in all 2019-11-17T09:06:00.662535+00:00 app[web.1]: return list(self) 2019-11-17T09:06:00.662537+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3342, in __iter__ 2019-11-17T09:06:00.662539+00:00 app[web.1]: return self._execute_and_instances(context) 2019-11-17T09:06:00.662541+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3367, in _execute_and_instances 2019-11-17T09:06:00.662544+00:00 app[web.1]: result = conn.execute(querycontext.statement, self._params) 2019-11-17T09:06:00.662546+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 988, in execute 2019-11-17T09:06:00.662548+00:00 app[web.1]: return meth(self, multiparams, params) 2019-11-17T09:06:00.662550+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 287, in _execute_on_connection 2019-11-17T09:06:00.662552+00:00 app[web.1]: return connection._execute_clauseelement(self, multiparams, params) 2019-11-17T09:06:00.662555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1107, in _execute_clauseelement 2019-11-17T09:06:00.662557+00:00 app[web.1]: distilled_params, 2019-11-17T09:06:00.662559+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1253, in _execute_context 2019-11-17T09:06:00.662562+00:00 app[web.1]: e, statement, parameters, cursor, context 2019-11-17T09:06:00.662564+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1473, in _handle_dbapi_exception 2019-11-17T09:06:00.662566+00:00 app[web.1]: util.raise_from_cause(sqlalchemy_exception, exc_info) 2019-11-17T09:06:00.662568+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 398, in raise_from_cause 2019-11-17T09:06:00.662570+00:00 app[web.1]: reraise(type(exception), exception, tb=exc_tb, cause=cause) 2019-11-17T09:06:00.662573+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 152, in reraise 2019-11-17T09:06:00.662575+00:00 app[web.1]: raise value.with_traceback(tb) 2019-11-17T09:06:00.662587+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1249, in _execute_context 2019-11-17T09:06:00.662590+00:00 app[web.1]: cursor, statement, parameters, context 2019-11-17T09:06:00.662592+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 580, in do_execute 2019-11-17T09:06:00.662594+00:00 app[web.1]: cursor.execute(statement, parameters) 2019-11-17T09:06:00.662596+00:00 app[web.1]: sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) relation "question" does not exist 2019-11-17T09:06:00.662599+00:00 app[web.1]: LINE 2: FROM question ORDER BY question.create_time DESC 2019-11-17T09:06:00.662601+00:00 app[web.1]: ^ 2019-11-17T09:06:00.662603+00:00 app[web.1]: 2019-11-17T09:06:00.662607+00:00 app[web.1]: [SQL: SELECT question.id AS question_id, question.title AS question_title, question.content AS question_content, question.create_time AS question_create_time, question.author_id AS question_author_id 2019-11-17T09:06:00.662609+00:00 app[web.1]: FROM question ORDER BY question.create_time DESC] ```
Traceback (most recent call last): File "structure.py"...
安装fastStructure软件,运行python structure.py,出现错误: ``` $ python structure.py Traceback (most recent call last): File "structure.py", line 3, in <module> import fastStructure File "vars/admixprop.pxd", line 5, in init fastStructure cdef class AdmixProp: File "allelefreq.pxd", line 7, in init admixprop ImportError: No module named allelefreq ``` 请问这个问题怎么解决?用的python2.7.15rc,fastStructure安装也都是按照软件说明步骤进行的。
python解析json格式数据时使用jsonpath无法取到值,返回false
jQuery183026400820446366513_1535963936721( { "records":[ { "id":"94406754893220", "memberid":"", "evaluationId":"0", "name":"S***.", "countryCode":"us", "countryName":"", "rank": "" , "buyerAccountPointLeval":"A1", "price":"", "quantity":"1", "unit":"piece", "lotNum":"1", "option":"", "star":"", "date":"31 Aug 2018 23:30", "buyerFeedback":"", "supplierReply":"", "buyerReply":"", "canDigg":"0" } , { "id":"94059567015926", "memberid":"", "evaluationId":"0", "name":"H***.", "countryCode":"us", "countryName":"", "rank": "" , "buyerAccountPointLeval":"A1", "price":"", "quantity":"1", "unit":"piece", "lotNum":"1", "option":"", "star":"", "date":"29 Aug 2018 22:32", "buyerFeedback":"", "supplierReply":"", "buyerReply":"", "canDigg":"0" } , { "id":"94058600254638", "memberid":"", "evaluationId":"0", "name":"M***.", "countryCode":"us", "countryName":"", "rank": "" , "buyerAccountPointLeval":"A1", "price":"", "quantity":"1", "unit":"piece", "lotNum":"1", "option":"", "star":"", "date":"29 Aug 2018 21:03", "buyerFeedback":"", "supplierReply":"", "buyerReply":"", "canDigg":"0" } , { "id":"94305519432368", "memberid":"", "evaluationId":"0", "name":"S***.", "countryCode":"ru", "countryName":"", "rank": "" , "buyerAccountPointLeval":"A1", "price":"", "quantity":"1", "unit":"piece", "lotNum":"1", "option":"", "star":"", "date":"29 Aug 2018 20:41", "buyerFeedback":"", "supplierReply":"", "buyerReply":"", "canDigg":"0" } , { "id":"702475432645369", "memberid":"", "evaluationId":"0", "name":"M***.", "countryCode":"ca", "countryName":"", "rank": "" , "buyerAccountPointLeval":"A1", "price":"", "quantity":"1", "unit":"piece", "lotNum":"1", "option":"", "star":"", "date":"29 Aug 2018 19:54", "buyerFeedback":"", "supplierReply":"", "buyerReply":"", "canDigg":"0" } ], "type":"default", "page":{ "current":"1", "total":"3" }, "range":{ "region":"6 months", "transactions":"43" } } ); 大佬们,这样的数据要怎么解析?
怎么把txt文件格式转化成json文件并且存入数据库中?
txt的文件内容如下,已经是标准的json格式 [{ "id":"1", "park_name":"a", "address":"A", "position":"22.695216,113.927461", "park_type":4, "_version_":1535810750513152000}, { "id":"2", "park_name":"b", "address":"B", "position":"22.691938,113.933866", "park_type":4, "_version_":1535810750594940928}, { "id":"3", "park_name":"C", "address":"c", "position":"22.688520,113.935555", "park_type":1, "_version_":1535810750594940929}, { "id":"4", "park_name":"D", "address":"d", "position":"22.689812,113.938286", "park_type":1, "_version_":1535810750594940930}, { "id":"5", "park_name":"E", "address":"e", "position":"22.689390,113.938376", "park_type":1, "_version_":1535810750594940931}] 在格式已经是json数据的格式的情况下,如何将txt文件转化成json 文件呢?最好用python语言来进行转化。
pyinstaller 打包python程序后出错,提示:"NoModuleFindError"
在用pyinstaller打包python程序 pyinstaller版本为:3.3.1 python 版本:3.6.1 系统版本:Windows-10-10.0.16299-SP0 ---------------------------------------------- 我的python程序名为:data_processing_gui.py 程序在python环境下正常运行。 打包使用的格式为:pyinstaller -F -p <导入的包路径> myprogram.py 完整打包命令为: ``` pyinstaller -F -p C:\Users\fanyu\Anaconda3\Lib;C:\Users\fanyu\Anaconda3\Lib\site-packages;C:\Users\fanyu\Anaconda3\Lib\site-packages\PyQt5\Qt\bin;C:\Users\fanyu\Anaconda3\Lib\site-packages\pydicom;C:\Users\fanyu\Anaconda3\Lib\site-packages\radiomics;C:\Users\fanyu\Anaconda3\Lib\site-packages\pywt;C:\Users\fanyu\Anaconda3\Lib\site-packages\pywt\_extensions;C:\Users\fanyu\Anaconda3\Lib\site-packages\tensorflow;C:\Users\fanyu\Anaconda3\Lib\site-packages\SimpleITK;C:\Users\fanyu\Anaconda3\Lib\site-packages\PIL;C:\Users\fanyu\Anaconda3\Lib\site-packages\pandas;C:\Users\fanyu\Anaconda3\Lib\site-packages\nrrd;C:\Users\fanyu\Anaconda3\Lib\site-packages\numpy -i C:\Users\fanyu\Desktop\work\package\image\doctor.ico data_processing_gui.py pause ``` 打包过程无报错,打包完成后运行程序提示出错信息: ``` Traceback (most recent call last): File "data_processing_gui.py", line 12, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\radiomics\__init__.py", line 15, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\radiomics\imageoperations.py", line 6, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pywt\__init__.py", line 17, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module exec(bytecode, module.__dict__) File "site-packages\pywt\_functions.py", line 17, in <module> File "c:\users\fanyu\anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 714, in load_module module = loader.load_module(fullname) File "pywt/_extensions/_pywt.pyx", line 1, in init pywt._extensions._pywt (pywt\_extensions\_pywt.c:31281) ModuleNotFoundError: No module named 'pywt._extensions._cwt' [7564] Failed to execute script data_processing_gui ``` 这里给出的错误是找不到包,但是打包时已包含了pywt._extensions的路径,不知什么地方有错误,求大神支招~
Python爬虫soup.findAll("li", {"class": "result"})为空
``` 大家好~ 我之前写的爬虫是单独针对某个页面的,比如新浪微博。这次需要在全网范围查询关于“开灯”有关的句子或文章,但是soup.findall("li",{"class":"result"})的结果一直是空。求助,谢谢。 PS:网上参考其他的例子,也都是在这个地方出问题,空的。。。 代码如下: #-*-coding:utf-8-*- __author__ = 'Daniel' #python3.5 #'爬取关于开灯的新闻' import re import urllib import chardet from bs4 import BeautifulSoup def remove_js_css(content): r = re.compile(r'''<scrip.*?</scrip>''', re.I|re.M|re.S) s = r.sub('', content) r = re.compile(r'''<style.*?</style>''', re.I|re.M|re.S) s = r.sub('', s) r = re.compile(r'''<!--.*?-->''', re.I|re.M|re.S) s = r.sub('', s) r = re.compile(r'''<meta.*?>''', re.I|re.M|re.S) s = r.sub('', s) r = re.compile(r'''<ins.*?</ins>''', re.I|re.M|re.S) s = r.sub('', s) return s def remove_empty_line(content): r = re.compile(r'''^\s+$''', re.M|re.S) s = r.sub('', content) r = re.compile(r'''\n+''', re.M|re.S) s = r.sub('\n', s) return s def remove_any_tag(s): s = re.sub(r'''<[^>]+>''', '', s) return s.strip() def remove_any_tag_but_a(s): text = re.findall(r'''<a[^r][^>]*>(.*?)</a>''', s, re.I|re.S|re.S) text_b = remove_any_tag(s) return len(''.join(text)), len(text_b) def remove_image(s, n=50): image = 'a' * n r = re.compile(r'''<img.*?>''', re.I|re.M|re.S) s = r.sub(image, s) return s def remove_video(s, n=1000): video = 'a' * n r = re.compile(r'''<embed.*?>''', re.I|re.M|re.S) s = r.sub(video, s) return s def sum_max(values): cur_max = values[0] glo_max = -99999 left, right = 0, 0 for index, value in enumerate(values): cur_max += value if(cur_max > glo_max): glo_max = cur_max right = index elif(cur_max < 0): cur_max = 0 for i in range(right, -1, -1): glo_max -= values[i] if abs(glo_max < 0.0001): left = i break return left, right + 1 def method_1(content, k = 1): if not content: return None, None, None, None tmp = content.split('\n') group_value = [] for i in range(0, len(tmp), k): group = '\n'.join(tmp[i:i+k]) group = remove_image(group) group = remove_video(group) text_a, text_b = remove_any_tag_but_a(group) temp = (text_b - text_a) - 8 group_value.append(tmp) left, right = sum_max(group_value) return left, right, len('\n'.join(tmp[:left])), len('\n'.join(tmp[:right])) def extract(content): content = remove_empty_line(remove_js_css(content)) left, right, x, y = method_1(content) return '\n'.join(content.split('\n')[left:right]) #输入url,将其新闻页的正文输入txt def extract_news_content(web_url, file_name): request = urllib.Request(web_url) #在请求加上头信息,伪装成浏览器访问 request.add_header('User-Agent','Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6') opener = urllib.build_opener() html = opener.open(request).read() infoencode = chardet.detect(html)['encoding']##通过第3方模块来自动提取网页的编码 if html != None and infoencode != None:#提取内容不为空,error.或者用else html = html.decode(infoencode, 'ignore') soup = BeautifulSoup(html) content = soup.renderContents() content_text = extract(content)#提取新闻网页中的正文部分,化为无换行的一段文字 content_text = re.sub("&nbsp;"," ",content_text) content_text = re.sub("&gt;","",content_text) content_text = re.sub("&quot;",'""',content_text) content_text = re.sub("<[^>]+>","",content_text) content_text = re.sub("\n","",content_text) file = open(file_name,'a')#append file.write(content_text) file.close() #抓取百度新闻搜索结果:中文搜索,前10页,url:key=关键词 def search(key_word): search_url = 'http://news.baidu.com/ns?word=key_word&tn=news&from=news&cl=2&rn=20&ct=1' req = urllib.request.urlopen(search_url.replace('key_word', key_word)) real_visited = 0 for count in range(10):#前10页 html = req.read() soup = BeautifulSoup(html) content = soup.findAll("li", {"class": "result"}) #resultset object num = len(content) for i in range(num): #先解析出来所有新闻的标题、来源、时间、url p_str = content[i].find('a') #if no result then nontype object contenttitle = p_str.renderContents() contenttitle = contenttitle.decode('utf-8', 'ignore')#need it contenttitle = re.sub("<[^>]+>", "", contenttitle) contentlink = str(p_str.get("href")) #存放顺利抓取的url,对比 visited_url = open(r'visited-cn.txt', 'r')#是否已经爬过 visited_url_list = visited_url.readlines() visited_url.close()#及时close exist = 0 for item in visited_url_list: if contentlink == item: exist = 1 if exist != 1:#如果未被访问url p_str2 = content[i].find('p').renderContents() contentauthor = p_str2[:p_str2.find("&nbsp;&nbsp")]#来源 contentauthor = contentauthor.decode('utf-8', 'ignore')#时 contenttime = p_str2[p_str2.find("&nbsp;&nbsp") + len("&nbsp;&nbsp") + 1:] contenttime = contenttime.decode('utf-8', 'ignore') #第i篇新闻,filename="D:\\Python27\\newscn\\%d.txt"%(i) #file = open(filename,'w'),一个txt一篇新闻 real_visited += 1 file_name = r"newscn\%d.txt"%(real_visited) file = open(file_name,'w') file.write(contenttitle.encode('utf-8')) file.write(u'\n') file.write(contentauthor.encode('utf-8')) file.write(u'\n') file.write(contenttime.encode('utf-8')) file.write(u'\n'+contentlink+u'\n') file.close() extract_news_content(contentlink, file_name)#还写入文件 visited_url_list.append(contentlink)#访问之 visited_url = open(r'visited-cn.txt', 'a')#标记为已访问,永久存防止程序停止后丢失 visited_url.write(contentlink+u'\n') visited_url.close() if len(visited_url_list) >= 120: break #解析下一页 if count == 0: next_num = 0 else: next_num = 1 next_page = 'http://news.baidu.com' + soup('a',{'href':True,'class':'n'})[next_num]['href'] # search for the next page#翻页 print(next_page) req = urllib.urlopen(next_page) if __name__=='__main__': #key_word = input('input key word:') key_word = 'helloworld' search(key_word) ```
Python解决嵌套for循环性能慢
``` 两个json文件关联 其中文件file1次取500条关file2 关联得到结果500条记录 目前情况是file2数据总数大概十万左右 for循环嵌套关联效率极低 ``` ###代码: ``` import json with open(file1,'r') as f1,open(file2,'r') as f2: a=json.load(f1) b=json.load(f2) list_a=[] for i in range(len(a)): for n in range(len(b)): if b[n]["id"]==a[i]["id"]: list_a.append(dict(b[n],**a[i])) f3=open(result,'w') as f3 json.dump(list_a, f3,sort_keys=True, ensure_ascii=False) f3.close() ``` ###1000条关联7万数据大概是两分钟 **file1 :** ``` [ { "id":"1", "name":"Tom" }, { "id":"2", "name":"Jim" }, { "id":"3", "name":"Bob" }, { "id":"4", "name":"Jeny" }, { "id":"5", "name":"Lara" }, { "id":"6", "name":"Lin" }, { "id":"7", "name":"Kim" }, { "id":"8", "name":"Jack" }, { "id":"9", "name":"Tony" } ] `` ##file2## ``` [ { "id":"1", "Details":[ { "label":"jcc", "hooby":"Swimming" }, { "label":"hkt", "hooby":"Basketball" }, ] }, { "id":"2", "Details":[ { "label":"NTC", "hooby":"Games" } ] }, { "id":"3", "Details":[ { "label":"Nill", "hooby":"BBQ" }, { "label":"hkt", "hooby":"PAY" }, ] }, { "id":"4", "Details":[ { "label":"HFF", "hooby":"Games" } ] }, { "id":"5", "Details":[ { "label":"Make", "hooby":"BBQ" } ] }, { "id":"6", "Details":[ { "label":"LLL", "hooby":"Games" } ] }, { "id":"7", "Details":[ { "label":"mmm", "hooby":"Games" } ] }, { "id":"8", "Details":[ { "label":"nnn", "hooby":"Games" } ] }, { "id":"9", "Details":[ { "label":"yyy", "hooby":"Games" } ] } ] ``` #### ##预期结果:## ``` [ { "id":"1", "name":"Tom", "Details":[ { "label":"jcc", "hooby":"Swimming" }, { "label":"hkt", "hooby":"Basketball" }, ] }, { "id":"2", "name":"Jim", "Details":[ { "label":"NTC", "hooby":"Games" } ] }, { "id":"3", "name":"Bob", "Details":[ { "label":"Nill", "hooby":"BBQ" }, { "label":"hkt", "hooby":"PAY" }, ] }, { "id":"4", "name":"Jeny", "Details":[ { "label":"HFF", "hooby":"Games" } ] }, { "id":"5", "name":"Lara", "Details":[ { "label":"Make", "hooby":"BBQ" } ] }, { "id":"6", "name":"Lin", "Details":[ { "label":"LLL", "hooby":"Games" } ] }, { "id":"7", "name":"Kim", "Details":[ { "label":"mmm", "hooby":"Games" } ] }, { "id":"8", "name":"Jack", "Details":[ { "label":"nnn", "hooby":"Games" } ] }, { "id":"9", "name":"Tony", "Details":[ { "label":"yyy", "hooby":"Games" } ] } ] ``` ``` 能不能把file1 map到一个里面然后只执行一次匹配 ```
Python,json转码,list of dictionaries遍历筛选
问题说明:原始数据导入字段index3就是json字符串格式(带单引号str),想要提取字典里面key值为"name"的所有value; ``` df_tmp #pandas dataframe #字段index3是json字符串格式(带单引号str),去掉单引号就是list of dics df_tmp["index3"][0] '[{"name": "Mary", "age":"7", "Sex":"F"},{"name":"Jack", "age":"11","Sex":"M"}]' df_tmp["index3"][1] '[{"name":"Jack", "age":"11","Sex":"M"},{"name":"Lucy","age":"9","Sex":"F"},{"name":"Nancy", "age":"10","Sex":"F"}]' df_tmp["index3"][2] '[{"name": "Luke", "age":"6", "Sex":"F"},{"name":"Lily", "age":"11","Sex":"F"}]' ``` 已有解决方案:把json转码成list of dictionaries,三层循环,遍历dataframe,遍历list,遍历字典; 问题:数据量稍微多一点,速度特别慢,python小白求大神想想其他的方案,比如pandas有没有好用的函数,可不可以用mysql处理?
如何使用python爬虫获取css伪元素例如:::before?
求助大神,在爬取网站的时候,网站对于部分文字使用伪元素::before进行了替换,导致无法爬取需要的数据。 例如:<span class="略">::before</span> ::before中隐藏了content后的汉字。 请问该如何处理? 十分感谢!
python处理txt文件,怎么把文本形式的数据处理成字典
如下: ``` {"item_id": 4036886, "title_features": {"1": 1, "2": 1, "3": 1, "4": 1, "5": 1, "6": 1}} {"item_id": 2893187, "title_features": {"8": 1, "9": 1, "7": 1}} {"item_id": 338441, "title_features": {"16": 1, "17": 1, "18": 1, "10": 1, "11": 1, "12": 1, "13": 1, "14": 1, "15": 1}} {"item_id": 2508763, "title_features": {"72": 1, "73": 1, "74": 1, "75": 1, "71": 1}} {"item_id": 305495, "title_features": {"80": 1, "76": 1, "77": 1, "78": 1, "79": 1}} {"item_id": 3096313, "title_features": {"81": 1, "82": 1, "83": 1, "84": 1, "85": 1, "86": 1}} ``` 节选了一段储存在文本文档里的数据,形式是字典的样子,怎么能处理成字典的储存方式呢? 谢谢各位前辈了!
关于vscode测试的问题,No tests discovered, please check the configuration settings for the tests.
![图片说明](https://img-ask.csdn.net/upload/201905/19/1558255180_546448.png) 每次打开vscode,都会弹出这个窗口。我尝试搜了一下网上的方法,有这种问题的貌似很少,仅找到的几个也解决不了 下面是我的settings.json,求前辈帮忙看看如何解决~ { "python.pythonPath": "E:\\Anaconda3\\python.exe", "python.linting.pylintEnabled": true, "python.linting.enabled": true, "python.testing.pyTestArgs": [ "platforms" ], "python.testing.unittestEnabled": true, "python.testing.nosetestsEnabled": false, "python.testing.pyTestEnabled": false, "python.testing.unittestArgs": [ "-v", "-s", ".", "-p", "test_*.py" ], "python.testing.nosetestArgs": [ "platforms" ] }
可以帮忙写个正则表达式吗?格式为"机器人添加 关键词:XXXXX 回答:YYYY"?
各位大神,小弟要用python处理文本,碰到一项任务,需要用正则表达式判断文本输入是否符合以下格式: * "机器人添加 关键词:XXXXX 回答:YYYY" 1. 其中XXXXX,YYYY是可变的,其余是固定的,并且两个冒号是中文冒号; 1. XXXXX,YYYY长度不定,可包含中文英文。但XXXXX只能是中英文,不能带有符号,而YYYY无此限定。 * 请各位大神帮帮忙,十分感谢!做伸手党内心惭愧,但无奈时间紧水平差,一点C币奉上
使用Python或Java解析Json文件,逐级打印菜单
有这样一个菜单json文件: {"id":"100" "name":"File" "parent":"#", "id":"200" "name":"Edit" "parent":"#", "id":"300" "name":"Search" "parent":"#", "id":"400" "name":"Project" "parent":"#", "id":"500" "name":"Help" "parent":"#", "id":"101" "name":"New" "parent":"100", "id":"102" "name":"Open" "parent":"100", "id":"103" "name":"Load" "parent":"100", "id":"201" "name":"Cut" "parent":"200", "id":"202" "name":"Copy" "parent":"200", "id":"203" "name":"Paste" "parent":"200", "id":"301" "name":"Back" "parent":"300", "id":"302" "name":"Replace" "parent":"300", "id":"303" "name":"Jump" "parent":"300", "id":"401" "name":"Add" "parent":"400", "id":"402" "name":"Remove" "parent":"400", "id":"403" "name":"Close" "parent":"400", "id":"501" "name":"Mode" "parent":"500", "id":"502" "name":"Key" "parent":"500", "id":"503" "name":"About" "parent":"500", "id":"1011" "name":"xx" "parent":"101", "id":"2011" "name":"yy" "parent":"201", "id":"3011" "name":"zz" "parent":"301", } 想要打印出如下结果: 100 File 100 File 101 New 100>101 File>New 1011 xx 100>101>1011 File>New>xx 102 Open 100>102 File>Open 103 Load 100>103 File>Load 200 Edit 200 Edit 201 Cut 200>201 Edit>Cut 2011 yy 200>201>2011 Edit>Cut>yy 202 Copy 200>202 Edit>Copy 203 Paste 200>203 Edit>Paste 300 Search 300 Search 301 Back 300>301 Search>Back 3011 zz 300>301>3011 Search>Back>zz 302 Replace 300>302 Search>Replace 303 Jump 300>303 Search>Jump 400 Project 400 Project 401 Add 400>401 Project>Add 402 Remove 400>402 Project>Remove 403 Close 400>403 Project>Close 500 Help 500 Help 501 Mode 500>501 Help>Mode 502 Key 500>502 Help>Key 503 About 500>503 Help>About 想要得出如下结果: 属性Parent如果为#时,说明这是一个根节点,直接打印,打印格式为 ID+Name+ID+Name 属性Parent如果非#时,则需要找到父节点的ID和Name,打印格式为 ID+Name+Parent ID>ID+Parent Name>Name 如果父节点也不是一个根节点,打印格式为 ID+Name+根节点ID>Parent ID>ID+根节点Name>Parent Name>Name,以此类推。当菜单层级非常多时,此处判断如何写一个递归算法,逐级找到某节点的所有父节点。
pyecharts 如何设置 树状图共用子节点
data是这样的,现在要实现B、C共用子节点E而不是另开辟一个子节点E ``` data = [ { "children": [ {"name": "B", "children": [ {"name": "E"}, ] }, { "children": [ {"children": [{"name": "I"}], "name": "E"}, {"name": "F"}, ], "name": "C", }, { "children": [ {"children": [{"name": "J"}, {"name": "K"}], "name": "G"}, {"name": "H"}, ], "name": "D", }, ], "name": "A", } ] ```
ubuntu中使用Python脚本连接mysql出错:pymysql.err.OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")
``` from pymysql import connect class JD(object): def __init__(self): pass def show_all_items(self): """显示所有的商品""" conn = connect(host="localhost",port=3306,user="root",password="root",database="jing_dong",charset="utf8") cursor = conn.cursor() cursor.execute("select * from goods;") for temp in cursor.fetchall(): print(temp) # 关闭Cursor对象 cursor.close() conn.close() def show_cates(self): conn = connect(host="localhost",port=3306,user="root",password="root",database="jing_dong",charset="utf8") cursor = conn.curson() cursor.execute("select name from goods_cates;") for temp in cursor.fetchall(): print(temp) # 关闭Cursor对象 cursor.close() conn.close() def run(self): while True: print("------欢迎来到京东商城------") print("1:所有的商品") print("2:所有的商品分类") print("3:所有的商品品牌分类") num = input("请输入功能对应的序号:") if num == "1": # 查询所有商品 self.show_all_items() elif num == "2": # 查询分类 self.show_cates() elif num == "3": # 查询商品分类 pass else: print("输入有错,请重新输入!") def main(): # 1.创建一个京东商城对象 jd = JD() # 2.调用这个对象的run方法,让其运行 jd.run() if __name__ == "__main__": main() ```
shc框架将dataframe写入Hbase int型会乱码
Python用shc框架将dataframe写入Hbase int型会乱码,而且读回df同样乱码 ``` df_test_HBase = sql_sc.read.format('jdbc').options(url=jdbc_url_test,driver=jdbc_driver,dbtable='testHBase').load() df_test_HBase.createOrReplaceTempView("test_HBase") df_cast_HBase = sql_sc.sql("select CAST(id as String) id,name,CAST(age as String) age,CAST(gender as String) gender,cat,tag,level from test_HBase") df_cast_HBase.show() dep = "org.apache.spark.sql.execution.datasources.hbase" catalog = """{ "table":{"namespace":"default", "name":"teacher", "tableCoder":"PrimitiveType"}, "rowkey":"key", "columns":{ "id":{"cf":"rowkey", "col":"key", "type":"string"}, "name":{"cf":"teacherBase", "col":"name", "type":"string"}, "age":{"cf":"teacherBase", "col":"age", "type":"string"}, "gender":{"cf":"teacherBase", "col":"gender","type":"string"}, "cat":{"cf":"teacherDetails", "col":"cat","type":"string"}, "tag":{"cf":"teacherDetails", "col":"tag", "type":"string"}, "level":{"cf":"teacherDetails", "col":"level","type":"string"} } } """ df_cast_HBase.write.options(catalog=catalog,newTable="5").format(dep).save() ``` 我目前只能通过Cast函数将int转成String并且把catalog中type为int也改成string后写入HBase才不乱码,但只是治标不治本,求大神给个治本的解决办法!! 前后对比图: ![图片说明](https://img-ask.csdn.net/upload/201904/28/1556424025_543013.png)
爬虫福利二 之 妹子图网MM批量下载
爬虫福利一:27报网MM批量下载    点击 看了本文,相信大家对爬虫一定会产生强烈的兴趣,激励自己去学习爬虫,在这里提前祝:大家学有所成! 目标网站:妹子图网 环境:Python3.x 相关第三方模块:requests、beautifulsoup4 Re:各位在测试时只需要将代码里的变量 path 指定为你当前系统要保存的路径,使用 python xxx.py 或IDE运行即可。
字节跳动视频编解码面经
三四月份投了字节跳动的实习(图形图像岗位),然后hr打电话过来问了一下会不会opengl,c++,shador,当时只会一点c++,其他两个都不会,也就直接被拒了。 七月初内推了字节跳动的提前批,因为内推没有具体的岗位,hr又打电话问要不要考虑一下图形图像岗,我说实习投过这个岗位不合适,不会opengl和shador,然后hr就说秋招更看重基础。我当时想着能进去就不错了,管他哪个岗呢,就同意了面试...
开源一个功能完整的SpringBoot项目框架
福利来了,给大家带来一个福利。 最近想了解一下有关Spring Boot的开源项目,看了很多开源的框架,大多是一些demo或者是一个未成形的项目,基本功能都不完整,尤其是用户权限和菜单方面几乎没有完整的。 想到我之前做的框架,里面通用模块有:用户模块,权限模块,菜单模块,功能模块也齐全了,每一个功能都是完整的。 打算把这个框架分享出来,供大家使用和学习。 为什么用框架? 框架可以学习整体...
Java学习的正确打开方式
在博主认为,对于入门级学习java的最佳学习方法莫过于视频+博客+书籍+总结,前三者博主将淋漓尽致地挥毫于这篇博客文章中,至于总结在于个人,实际上越到后面你会发现学习的最好方式就是阅读参考官方文档其次就是国内的书籍,博客次之,这又是一个层次了,这里暂时不提后面再谈。博主将为各位入门java保驾护航,各位只管冲鸭!!!上天是公平的,只要不辜负时间,时间自然不会辜负你。 何谓学习?博主所理解的学习,它是一个过程,是一个不断累积、不断沉淀、不断总结、善于传达自己的个人见解以及乐于分享的过程。
Spring Boot2 系列教程(十七)SpringBoot 整合 Swagger2
前后端分离后,维护接口文档基本上是必不可少的工作。 一个理想的状态是设计好后,接口文档发给前端和后端,大伙按照既定的规则各自开发,开发好了对接上了就可以上线了。当然这是一种非常理想的状态,实际开发中却很少遇到这样的情况,接口总是在不断的变化之中,有变化就要去维护,做过的小伙伴都知道这件事有多么头大!还好,有一些工具可以减轻我们的工作量,Swagger2 就是其中之一,至于其他类似功能但是却收费的软...
Python 基础(一):入门必备知识
目录1 标识符2 关键字3 引号4 编码5 输入输出6 缩进7 多行8 注释9 数据类型10 运算符10.1 常用运算符10.2 运算符优先级 1 标识符 标识符是编程时使用的名字,用于给变量、函数、语句块等命名,Python 中标识符由字母、数字、下划线组成,不能以数字开头,区分大小写。 以下划线开头的标识符有特殊含义,单下划线开头的标识符,如:_xxx ,表示不能直接访问的类属性,需通过类提供
天天学JAVA-JAVA基础(6)
如果觉得我写的还行,请关注我的博客并且点个赞哟。本文主要介绍JAVA 中最常使用字符串常量String相关知识。 1.String简介 2.创建字符串对象两种方式的区别 3.String常用的方法 4.String的不可变性 5.一道阿里面试题,你会做吗? 1.String简介 1.1String源码 首先看一段String源码,String主要实现了Serializable、Compar...
程序员接私活怎样防止做完了不给钱?
首先跟大家说明一点,我们做 IT 类的外包开发,是非标品开发,所以很有可能在开发过程中会有这样那样的需求修改,而这种需求修改很容易造成扯皮,进而影响到费用支付,甚至出现做完了项目收不到钱的情况。 那么,怎么保证自己的薪酬安全呢? 我们在开工前,一定要做好一些证据方面的准备(也就是“讨薪”的理论依据),这其中最重要的就是需求文档和验收标准。一定要让需求方提供这两个文档资料作为开发的基础。之后开发
Python十大装B语法
Python 是一种代表简单思想的语言,其语法相对简单,很容易上手。不过,如果就此小视 Python 语法的精妙和深邃,那就大错特错了。本文精心筛选了最能展现 Python 语法之精妙的十个知识点,并附上详细的实例代码。如能在实战中融会贯通、灵活使用,必将使代码更为精炼、高效,同时也会极大提升代码B格,使之看上去更老练,读起来更优雅。 1. for - else 什么?不是 if 和 else 才
数据库优化 - SQL优化
前面一篇文章从实例的角度进行数据库优化,通过配置一些参数让数据库性能达到最优。但是一些“不好”的SQL也会导致数据库查询变慢,影响业务流程。本文从SQL角度进行数据库优化,提升SQL运行效率。 判断问题SQL 判断SQL是否有问题时可以通过两个表象进行判断: 系统级别表象 CPU消耗严重 IO等待严重 页面响应时间过长
2019年11月中国大陆编程语言排行榜
2019年11月2日,我统计了某招聘网站,获得有效程序员招聘数据9万条。针对招聘信息,提取编程语言关键字,并统计如下: 编程语言比例 rank pl_ percentage 1 java 33.62% 2 c/c++ 16.42% 3 c_sharp 12.82% 4 javascript 12.31% 5 python 7.93% 6 go 7.25% 7
通俗易懂地给女朋友讲:线程池的内部原理
餐盘在灯光的照耀下格外晶莹洁白,女朋友拿起红酒杯轻轻地抿了一小口,对我说:“经常听你说线程池,到底线程池到底是个什么原理?”
经典算法(5)杨辉三角
写在前面: 我是 扬帆向海,这个昵称来源于我的名字以及女朋友的名字。我热爱技术、热爱开源、热爱编程。技术是开源的、知识是共享的。 这博客是对自己学习的一点点总结及记录,如果您对 Java、算法 感兴趣,可以关注我的动态,我们一起学习。 用知识改变命运,让我们的家人过上更好的生活。 目录一、杨辉三角的介绍二、杨辉三角的算法思想三、代码实现1.第一种写法2.第二种写法 一、杨辉三角的介绍 百度
腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹?
昨天,有网友私信我,说去阿里面试,彻底的被打击到了。问了为什么网上大量使用ThreadLocal的源码都会加上private static?他被难住了,因为他从来都没有考虑过这个问题。无独有偶,今天笔者又发现有网友吐槽了一道腾讯的面试题,我们一起来看看。 腾讯算法面试题:64匹马8个跑道需要多少轮才能选出最快的四匹? 在互联网职场论坛,一名程序员发帖求助到。二面腾讯,其中一个算法题:64匹
2020 网络课 智慧树自动刷课代码,自动跳转,自动答题并关闭弹窗,自动1.5倍速静音
刷课一时爽,一直刷课一直爽! 终于让我找到了这个黑客代码了,教程开始: 只限谷歌浏览器和火狐浏览器使用,如果第一次失败,请重新试一下次 将下面代码复制后,进入浏览器按F12键,先点击console 然后Ctrl+v复制代码 最后按回车键即可 var ti = $("body"); var video = $(".catalogue_ul1 li[id*=video-]"); var i = 1;...
面试官:你连RESTful都不知道我怎么敢要你?
面试官:了解RESTful吗? 我:听说过。 面试官:那什么是RESTful? 我:就是用起来很规范,挺好的 面试官:是RESTful挺好的,还是自我感觉挺好的 我:都挺好的。 面试官:… 把门关上。 我:… 要干嘛?先关上再说。 面试官:我说出去把门关上。 我:what ?,夺门而去 文章目录01 前言02 RESTful的来源03 RESTful6大原则1. C-S架构2. 无状态3.统一的接
为啥国人偏爱Mybatis,而老外喜欢Hibernate/JPA呢?
关于SQL和ORM的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行了一番讨论,感触还是有一些,于是就有了今天这篇文。 声明:本文不会下关于Mybatis和JPA两个持久层框架哪个更好这样的结论。只是摆事实,讲道理,所以,请各位看官勿喷。 一、事件起因 关于Mybatis和JPA孰优孰劣的问题,争论已经很多年了。一直也没有结论,毕竟每个人的喜好和习惯是大不相同的。我也看
SQL-小白最佳入门sql查询一
一 说明 如果是初学者,建议去网上寻找安装Mysql的文章安装,以及使用navicat连接数据库,以后的示例基本是使用mysql数据库管理系统; 二 准备前提 需要建立一张学生表,列分别是id,名称,年龄,学生信息;本示例中文章篇幅原因SQL注释略; 建表语句: CREATE TABLE `student` ( `id` int(11) NOT NULL AUTO_INCREMENT, `
项目中的if else太多了,该怎么重构?
介绍 最近跟着公司的大佬开发了一款IM系统,类似QQ和微信哈,就是聊天软件。我们有一部分业务逻辑是这样的 if (msgType = "文本") { // dosomething } else if(msgType = "图片") { // doshomething } else if(msgType = "视频") { // doshomething } else { // dosho
致 Python 初学者
文章目录1. 前言2. 明确学习目标,不急于求成,不好高骛远3. 在开始学习 Python 之前,你需要做一些准备2.1 Python 的各种发行版2.2 安装 Python2.3 选择一款趁手的开发工具3. 习惯使用IDLE,这是学习python最好的方式4. 严格遵从编码规范5. 代码的运行、调试5. 模块管理5.1 同时安装了py2/py35.2 使用Anaconda,或者通过IDE来安装模
“狗屁不通文章生成器”登顶GitHub热榜,分分钟写出万字形式主义大作
一、垃圾文字生成器介绍 最近在浏览GitHub的时候,发现了这样一个骨骼清奇的雷人项目,而且热度还特别高。 项目中文名:狗屁不通文章生成器 项目英文名:BullshitGenerator 根据作者的介绍,他是偶尔需要一些中文文字用于GUI开发时测试文本渲染,因此开发了这个废话生成器。但由于生成的废话实在是太过富于哲理,所以最近已经被小伙伴们给玩坏了。 他的文风可能是这样的: 你发现,
程序员:我终于知道post和get的区别
IT界知名的程序员曾说:对于那些月薪三万以下,自称IT工程师的码农们,其实我们从来没有把他们归为我们IT工程师的队伍。他们虽然总是以IT工程师自居,但只是他们一厢情愿罢了。 此话一出,不知激起了多少(码农)程序员的愤怒,却又无可奈何,于是码农问程序员。 码农:你知道get和post请求到底有什么区别? 程序员:你看这篇就知道了。 码农:你月薪三万了? 程序员:嗯。 码农:你是怎么做到的? 程序员:
羞,Java 字符串拼接竟然有这么多姿势
二哥,我今年大二,看你分享的《阿里巴巴 Java 开发手册》上有一段内容说:“循环体内,拼接字符串最好使用 StringBuilder 的 append 方法,而不是 + 号操作符。”到底为什么啊,我平常一直就用的‘+’号操作符啊!二哥有空的时候能否写一篇文章分析一下呢? 就在昨天,一位叫小菜的读者微信我说了上面这段话。 我当时看到这条微信的第一感觉是:小菜你也太菜了吧,这都不知道为啥啊!我估...
写1行代码影响1000000000人,这是个什么项目?
不带钱不带卡,只带手机出门就能畅行无阻,这已是生活的常态。益普索发布的《2019第一季度第三方移动支付用户研究》报告显示,移动支付在手机网民中的渗透率高达95.1%,截至今年1月,支付宝全球用户数已经突破10亿。你或许每天都会打开支付宝,付款购物、领取权益、享受服务……但你或许不知道的是,在这个方便、快捷、智能化的APP背后,有一群年轻的技术人,用智慧和创新让它每天都变得更“聪明”一点。 ...
《程序人生》系列-这个程序员只用了20行代码就拿了冠军
你知道的越多,你不知道的越多 点赞再看,养成习惯GitHub上已经开源https://github.com/JavaFamily,有一线大厂面试点脑图,欢迎Star和完善 前言 这一期不算《吊打面试官》系列的,所有没前言我直接开始。 絮叨 本来应该是没有这期的,看过我上期的小伙伴应该是知道的嘛,双十一比较忙嘛,要值班又要去帮忙拍摄年会的视频素材,还得搞个程序员一天的Vlog,还要写BU
程序员把地府后台管理系统做出来了,还有3.0版本!12月7号最新消息:已在开发中有github地址
第一幕:缘起 听说阎王爷要做个生死簿后台管理系统,我们派去了一个程序员…… 996程序员做的梦: 第一场:团队招募 为了应对地府管理危机,阎王打算找“人”开发一套地府后台管理系统,于是就在地府总经办群中发了项目需求。 话说还是中国电信的信号好,地府都是满格,哈哈!!! 经常会有外行朋友问:看某网站做的不错,功能也简单,你帮忙做一下? 而这次,面对这样的需求,这个程序员
网易云6亿用户音乐推荐算法
网易云音乐是音乐爱好者的集聚地,云音乐推荐系统致力于通过 AI 算法的落地,实现用户千人千面的个性化推荐,为用户带来不一样的听歌体验。 本次分享重点介绍 AI 算法在音乐推荐中的应用实践,以及在算法落地过程中遇到的挑战和解决方案。 将从如下两个部分展开: AI 算法在音乐推荐中的应用 音乐场景下的 AI 思考 从 2013 年 4 月正式上线至今,网易云音乐平台持续提供着:乐屏社区、UGC
一点一滴记录 Java 8 stream 的使用
日常用到,一点一滴记录,不断丰富,知识积累,塑造自身价值。欢迎收藏 String 转 List String str = 1,2,3,4; List&lt;Long&gt; lists = Arrays.stream(str.split(",")).map(s -&gt; Long.parseLong(s.trim())).collect(Collectors.toList()); Lis...
8年经验面试官详解 Java 面试秘诀
    作者 | 胡书敏 责编 | 刘静 出品 | CSDN(ID:CSDNnews) 本人目前在一家知名外企担任架构师,而且最近八年来,在多家外企和互联网公司担任Java技术面试官,前后累计面试了有两三百位候选人。在本文里,就将结合本人的面试经验,针对Java初学者、Java初级开发和Java开发,给出若干准备简历和准备面试的建议。   Java程序员准备和投递简历的实
面试官如何考察你的思维方式?
1.两种思维方式在求职面试中,经常会考察这种问题:北京有多少量特斯拉汽车? 某胡同口的煎饼摊一年能卖出多少个煎饼? 深圳有多少个产品经理? 一辆公交车里能装下多少个乒乓球? 一
相关热词 如何提升c#开发能力 矩阵乘法c# c#调用谷歌浏览器 c# 去空格去转义符 c#用户登录窗体代码 c# 流 c# linux 可视化 c# mvc 返回图片 c# 像素空间 c# 日期 最后一天
立即提问