写了个小工具,其中涉及到从远程数据库中查询并返回,数据库是utf8编码,但是我的工具用的是GB2312编码,因此在返回数据的时候,有部分数据出现了:Truncated incorrect DECIMAL value 的警告信息. 但是并不妨碍工具获取查询结果和后续操作,只是每次运行,都会出现几行告警信息,实在很难看.在网上查了一下,发现,如果是通过命令提示符运行.py文件,可以忽略告警.例如我的代码文件是"test.py",则可在命令提示符中输入: python -W ignore t
直接贴代码了: NewsInfo 实体类: public class NewsInfo { public int NewsInfoId { get; set; } public string NewsInfoTitle { get; set; } public int? NewsTypeId { get; set; } public virtual NewsType NewsTypeInfo { get; set; } } NewsType 实体类: public class NewsType
1.将网址在页面上打开可以正常访问,但是用file_get_content请求则访问不到.这个是因为对方挡住了非浏览器访问导致的.需要改下php配置,模拟浏览器访问. user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)" 2.这只是其中一个原因,还有一些网站做了cookie验证,这个时候就需要模拟cookie
如下所示,看了网上的几种方法,这种方法算是代码量比较小的,同时可以保证求的是本地时区的0点时间戳,返回的是浮点数,需要的话自己转一下int In [1]: import time In [2]: from datetime import datetime In [3]: time.mktime(datetime.now().date().timetuple()) Out[3]: 1532188800.0
经过上一篇,里面有测试代码,循环60万次,耗时14秒.本次我们增加缓存来优化它. DbContextExtensions.cs using System; using System.Collections.Generic; using System.Data.Entity; using System.Data.Entity.Core.Mapping; using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Infr
接着上一篇,我们继续来优化. 直接贴代码了: LambdaHelper.cs using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; namespace EntityFrameworkSample { public static class LambdaHelp
接着上一篇 直接贴代码了: using System; using System.Collections.Generic; using System.Data.Entity; using System.Data.Entity.Core.Mapping; using System.Data.Entity.Core.Metadata.Edm; using System.Data.Entity.Infrastructure; using System.Data.Entity.ModelConfigur