摘要: #!/usr/bin/env python #coding:utf-8 import paramiko ssh=paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) private_key=paramiko.RSAKey.from_private_key_file('id_rsa'... 阅读全文
posted @ 2017-03-13 13:54 alston-lee 阅读(175) 评论(0) 推荐(0) 编辑
摘要: def show(*args,**kwargs): print(args,type(args)) print(kwargs,type(kwargs)) show(1,2,3,4,k1='v1',k2='v2') l=[1,2,3,4] b={'k1':'v1','k2':'v2'} show(l,b) show(*l,**b) 阅读全文
posted @ 2017-03-10 15:26 alston-lee 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 1 import threading,time 2 3 4 event=threading.Event() 5 6 7 def lighter(): 8 count=0 9 10 while True: 11 if count =5 and count<10: 15 print('red ...')... 阅读全文
posted @ 2017-03-03 16:34 alston-lee 阅读(950) 评论(0) 推荐(0) 编辑
摘要: 客户端 服务端: 阅读全文
posted @ 2017-03-02 13:00 alston-lee 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 常用正则表达式符号 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 '.' 默认匹配除\n之外的任意一个字符,若指定flag DOTALL,则匹配任意字符,包括换行 '^' 匹配字符开头,若指定flags MULTILINE,这种也可以匹 阅读全文
posted @ 2017-02-20 16:26 alston-lee 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 很多程序都有记录日志的需求,并且日志中包含的信息即有正常的程序访问日志,还可能有错误、警告等信息输出,python的logging模块提供了标准的日志接口,你可以通过它存储各种格式的日志,logging的日志可以分为 debug(), info(), warning(), error() and c 阅读全文
posted @ 2017-02-20 16:25 alston-lee 阅读(112) 评论(0) 推荐(0) 编辑
摘要: import xml.etree.ElementTree as ET tree=ET.parse('demo.xml') root=tree.getroot() for child in root: print(child.tag,child.attrib) for i in child: print(i.tag,i.text) 阅读全文
posted @ 2017-02-20 15:23 alston-lee 阅读(89) 评论(0) 推荐(0) 编辑
摘要: 一:内建模块 1. time和datetime(http://www.jb51.net/article/49326.htm)在Python中,通常有这几种方式来表示时间:1)时间戳 2)格式化的时间字符串 3)元组(struct_time)共九个元素。由于Python的time模块实现主要调用C库, 阅读全文
posted @ 2017-02-20 11:13 alston-lee 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 #!/usr/bin/env python 2 #coding:utf-8 3 4 #迭代对象:可以用于被for循环的对象Iterable 5 #可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iterator 6 7 from collections import Iterable 8 9 s=[1,2,3,4,5,6] 10 11 if isi... 阅读全文
posted @ 2017-02-15 16:38 alston-lee 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 增加多种类型验证 阅读全文
posted @ 2017-02-15 14:20 alston-lee 阅读(197) 评论(0) 推荐(0) 编辑