08 2013 档案
摘要:A non-empty zero-indexed array A consisting of N integers is given. Thefirst covering prefixof array A is the smallest integer P such that 0≤P0:12 if a[length]:13 length-=114 else:15 break16 return length用python自带的字典来实现哈希表的功能BTW:最后得分100的感觉爽爆了
阅读全文
摘要:You are given N round clocks.Every clock has M hands, and these hands can point to positions 1, 2, 3, ..., P (yes, these represent numbers around each face). The clocks are represented by the matrix A consisting of N rows and M columns of integers. The first row represents the hands of the first clo
阅读全文
摘要:1.python的ElementTree的用法 这部分的内容主要来自对python 3.3.2的documentation的翻译 sample.xml: 1 2008 141100 4 2011 59900 68 2011 13600 从文件导入数据或者从字符串导入:import xml.etree.ElementTree as ETtre...
阅读全文
摘要:1.针对接口编程 接口是一系列方法的声明,是一些方法特征的集合,一个接口只有方法的特征没有方法的实现. 接口是对抽象的抽象 针对接口编程也称为面向接口编程,将设计和实现分开,使用时只需引用借口即可,用于系统各部分的解耦合.2.单一职责原则 定义:一个类的功能要单一,只做与它相关的事情. 遵循单一职责原则会给测试带来极大的方便. 违背单一职责原则会降低类的内聚性,增强类的耦合性.3.开放封闭原则 定义:一个软件实体应当对扩展开放,对修改关闭.开放封闭原则是面向对象原则的核心. 封装变化,以来接口和抽象类,而不要依赖具体实现类.要针对接口和抽象类编程,不要针对具体实现编程. 我们无法控制变化,但我
阅读全文
摘要:python处理xml报错:xml.etree.ElementTree.ParseError: not well-formed (invalid token):查询得知xml有不支持的字符范围出现这个错误的原因是,xml文件中含有非法字符,是一个bad xml,即不符合xml规范的.由于xml文件是第三方提供,只能自己这里处理掉xml中的非法字符python过滤方法: text=open("badxml.xml").read() text=re.sub(u"[\x00-\x08\x0b-\x0c\x0e-\x1f]+",u"",tex
阅读全文

浙公网安备 33010602011771号