12 2017 档案
摘要:slice: eg: >>>e=[0,1,2,3,4,5,6] >>>s=slice(2,3) >>>e[s] [2] slice的区间左闭右开[) >>>s slice(2,3,None) slice([strar,]stop[,step]),start缺少时就是0 indices: eg: >>
阅读全文
摘要:问题:怎样在Python的一个序列上面保持元素顺序的同时消除重复的值?answer:如果序列上的值都是hashable 类型,那么可以很简单的利用集合或者生成器来解决这个问题。 eg1: def dedupe(items): seen = set() for item in items: if it
阅读全文
摘要:def CreateGenerator(file): with open(file,'r') as t: t.seek(0,2) while True: line=t.readline() if not line: time.sleep(0.1) continue yield line g=Crea
阅读全文
摘要:计算机==>右键==>属性==>高级系统设置==>环境变量==> 系统变量path后面+';python路径名
阅读全文
摘要:1)ctrl+c,退出命令 2)q,退出文件
阅读全文
摘要:git bash是Windows下的命令行工具 安装后在任何一个文件夹下右键GitBash,打开一个窗口,ssh root@xx.xxx.xxx.xx登陆到服务器,输入yes,和登陆密码可以使用敲命令了
阅读全文
摘要:问题:怎么样在两个字典中找相同点 answer: eg1: 下面2个字典 a={'x':1,'y':2,'z':3}, b={'w':10,'x':11,'y':2}, 1)找相同点: a.keys & b.keys() 2)Find keys in a that are not in b: a.k
阅读全文
摘要:problem: 怎样在数据字典中执行一些计算操作(比如求最小值、最大值、排序等等)? answer: eg1: 考虑下面的股票名和价格映射字典: prices = {'ACME': 45.23,'AAPL': 612.78,'IBM': 205.55,'HPQ': 37.20,'FB': 10.7
阅读全文