摘要: socket.getservbyname(servicename[, protocolname]) –> integer查询某个协议对应的端口号,需要使用两个参数,servicename对应端口名称,如 http, smtp,等。protocolname对应tcp,udp。s.getsockname()s.getpeername()getsockname: Return the address of the local endpoint. For IP sockets, the address info is a pair (hostaddr, port)getpeername: Ret 阅读全文
posted @ 2013-02-26 10:55 roicel 阅读(530) 评论(0) 推荐(1) 编辑
摘要: 不过多的介绍Selenium的历史以及应该使用哪个版本进行测试了。这只是我的学习笔记,方便以后回顾新的知识。Selenium的命令—SeleneseSelenese---Selenium提供的可以进行全面的Web应用测试的命令的总称。可以通过http://release.seleniumhq.org/selenium-core/1.0.1/reference.html 查询。该命令主要有三种子类型,Actions、Accessors和 Assertions:1. Actions决定Selenium工具怎样操作Web系统,如:点击某个链接和选择某个下拉选项,若一个Action执行失败或发生错误, 阅读全文
posted @ 2013-02-25 23:17 roicel 阅读(624) 评论(0) 推荐(0) 编辑
摘要: 目前我的工作是在一家开发并生产网络安全设备的公司做测试,在工作过程中要与各种协议(ftp,smtp,pop3,tcp,udp,http)打交道,并且在工作过程中还会涉及到性能测试及自动化测试,所以打算趁着现在工作的机会,可以把python应用到日常的工作中。ok,废话不说了,进入正题了。python提供了访问底层操作系统Socket的全部方法,还提供了一些用于加密和认证通信的服务,如SSL/TLS。在建立socket对象的时候,需要告诉系统两件事情:通信类型(IPv4, IPv6等)和协议(规定数据如何被传输)。对于现阶段而言,通信类型基本上都是AF_INET(IPv4),协议一般表示TCP通 阅读全文
posted @ 2013-02-22 15:50 roicel 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 1 ten = set(range(10)) 2 lows = set([0, 1, 2, 3, 4]) 3 odds = set([1, 3, 5, 7, 9]) 4 5 lows.add(9) # lows set([0,1,2,3,4,9]) 6 lows.difference(odds) # set([0, 2, 4]) 7 lows.intersection(odds) # set([1,3 ,9]) 8 lows.issubset(ten) # True 9 lows.issuperset(odds) # False10 lows.remove(0)11 lows.symmet.. 阅读全文
posted @ 2013-01-10 22:02 roicel 阅读(598) 评论(0) 推荐(0) 编辑
摘要: import sysdef process_file(filename): '''Open, read, and print a file.''' input_file = open(filename, "r") for line in input_file: line = line.strip() print line input_file.close()if __name__ == '__main__': process_file(sys.argv[1]) 此代码的运行方式为 python 文件名 sy.. 阅读全文
posted @ 2013-01-10 21:33 roicel 阅读(237) 评论(0) 推荐(1) 编辑
摘要: 如果要用python匹配字符串的开头或末尾是否包含一个字符串,就可以用startswith,和endswith比如:content = 'ilovepython'如果字符串content以ilove开始,返回True,否则返回Falsecontent.startswith("ilove")返回truecontent.startswith("sss")返回false如果字符串content以python结尾,返回True,否则返回Falsecontent.endswith('python')返回truecontent.end 阅读全文
posted @ 2013-01-10 21:25 roicel 阅读(236) 评论(0) 推荐(0) 编辑