自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(79)
  • 收藏
  • 关注

原创 C/S通讯模型

#server端:"""服务端创建socket步骤:1、创建socket对象 -> 2、绑定Ip及端口号 -> 3、监听端口号,等待客户端请求 ->响应客户端请求"""import socketimport timesock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)print type(sock)sock.bind(('

2016-10-07 23:04:35 591

原创 python多线程

#-*-coding:utf-8-*-'''Created on 2016年9月17日@author: zroad'''import threadingfrom time import ctime,sleepdef music(func): for i in range(2): print "I was listening to %s. %s" %(func,cti

2016-09-17 22:43:49 388

原创 以Html格式输出自动化测试报告

#-*-coding:utf-8-*-'''Created on 2016年9月13日@author: zroad'''from selenium import webdriverfrom HTMLTestRunner import HTMLTestRunnerimport unittestimport timeclass Baidu(unittest.TestCase): def

2016-09-15 22:44:20 3813

转载 const关键字

/* * constDecorate.cpp * * Created on: 2016年8月31日 * Author: zroad */#include<iostream>using namespace std;//三、const修饰类的成员方法://1、该成员函数无法修改成员变量//2、该成员函数无法调用非const成员函数class ConstIns{public

2016-09-05 00:00:26 301

原创 空指针与野指针

/* * zeroPoint.cpp * * Created on: 2016年8月29日 * Author: zroad */#include<iostream>#include<string>#include<cstring>#include<stdlib.h>using namespace std;class A {public: void Func(v

2016-08-29 23:16:06 543

原创 函数对象

/* * funcObject.cpp * * Created on: 2016年8月26日 * Author: zroad */#include<iostream>#include<string>using namespace std;//一、函数对象的概念//函数对象:即一个重载了括号操作符"()"的对象。当用该对象调用此操作符时,//其表现形式如同普通函数调用一般,

2016-08-26 22:24:47 406

原创 虚函数及纯虚函数

/* * virtualVar.cpp * * Created on: 2016年8月24日 * Author: zroad */#include<iostream>using namespace std;//一。虚函数的概念:/* * 1、虚函数的定义:类Base中加了Virtual关键字的函数就是虚拟函数(例如函数print), * 2、多态的实现:于是在Base

2016-08-25 00:02:47 260

转载 virtual关键字及多态的实现

virtual关键字

2016-08-24 22:02:28 397

原创 函数指针

/* * functionPoint.cpp * * Created on: 2016年8月22日 * Author: zroad */#include<iostream>using namespace std;//函数指针的概念:/* * 函数指针: * 1.函数的一个属性就是其地址指明了函数体在内存中的位置。 * 2、C在编译时,每一个函数都有一个入口地址,该入口

2016-08-22 23:25:36 285

原创 指针与引用变量

#include<iostream>#include<string>using namespace std;int main() { int n = 5, *p = &n, &r = n; cout << n << " " << *p << " " << r << endl; n = 7; cout << n << " " << *p << " " << r <<

2016-08-18 23:27:49 237

原创 析构函数

/* * deleteFunc.cpp * * Created on: 2016年8月17日 * Author: zroad */#include<string>#include<iostream>using namespace std;bool being = true;class Fruit {public: void print() { cou

2016-08-17 22:58:22 249

原创 struct基础

/* * structBase.cpp * * Created on: 2016年8月1日 * Author: zroad */#include<iostream>#include<cstring>using namespace std;int main() { //一、声明结构体: //结构体:由一系列具有相同类型或不同类型的数据构成的数据集合,也叫结构

2016-08-02 00:22:51 312

原创 指针与数组

/* * pointArray.cpp * * Created on: 2016年7月21日 * Author: zroad */#include<iostream>#include<string>using namespace std;//数组初始化1string b[4] = {"a", "b", "c", "d"};//数组初始化2/* * 未初始化数据规则:

2016-07-21 22:27:27 249

原创 指针变量

/* * pointDemo.cpp * * Created on: 2016年7月20日 * Author: zroad */#include<iostream>using namespace std;void pointVar() { //变量j若未初始化,系统将随即给该变量赋值 int i = 15, j, *p, *q; cout << "i=

2016-07-20 23:15:55 273

原创 类继承、虚继承

/* * inheritClass.cpp * * Created on: 2016年7月18日 * Author: zroad */#include<iostream>#include<cstring>using namespace std;class BaseClass {public: BaseClass() {} void f(char *s = "

2016-07-18 22:09:38 309

原创 c++类实例化的两种方式

/* * HelloWorld.cpp * * Created on: 2016年7月13日 * Author: zroad */#include<iostream>#include<cstring>#include<string>using namespace std;class C {public: C(string s = "", int i = 0, d

2016-07-16 22:57:40 20326 1

原创 对字符串进行MD5加密

"""Md5编码1、MD5码是不能够反向破译的2、同一对象每次加密的结果是一样的"""import hashlibhash = hashlib.md5()print "type(hash)=", type(hash)hash.update('zroad')print hash.hexdigest()#print hash.digest()hash1 = hashlib.md5()

2016-05-22 22:21:46 1108

原创 使用unittest.TestSuite组织执行用例

#-*-coding:utf-8-*-'''Created on 2016年4月11日@author: Zroad'''import calculatorimport unittestclass TestSuiteForCount(unittest.TestCase): def setUp(self): print "Test start ......" def

2016-04-11 23:27:49 6238

原创 unittest单元测试框架运行流程解析

#-*-coding:utf-8-*-"""定义待测试类calculator.py"""class Count(object): def __init__(self,a,b): self.a = int(a) self.b = int(b) def add(self): return self.a + self.bimport cal

2016-04-10 23:44:07 2940

原创 字符串常量

#-*-coding:utf-8-*-'''Created on 2016年3月29日@author: Zroad'''"""一、字符串常量:字符串类型分为如下两种:1、str类型:ASC||编码,Python默认的编码方式,不能表示汉字2、unicode类型:Unicode编码,表示汉字、日、韩文等,字符串钱加'u','U'"""#1、字符串的表示方式print 'spa"m'

2016-03-30 00:12:47 584

原创 动态类型详解

#-*-coding:utf-8-*-'''Created on 2016年3月27日@author: Zroad'''#动态类型:类型是在运行过程中自动决定的,而不是通过代码声明"""一、动态语言赋值的操作过程,以 a = 3为例,分三步完成:1、创建一个对象来代表值3。2、创建一个变量a,如果它还未创建的话3、将变量与新的对象3连接起来""""""二、关于变量、引用、与对象a

2016-03-27 23:54:31 444

原创 函数参数二:不同种类型函数参数及其调用

#-*-coding:utf-8-*-'''Created on 2016年3月24日@author: Zroad'''#1、位置参数,从左至右进行匹配def f1(a,b,c): print a,b,cf1(3,2,1) #3 2 1f1(19,9,29) #19 9 29#2、关键字参数:通过参数名进行匹配def f2(a,b,c): print a,b,cf2(c=

2016-03-24 23:50:26 630

原创 集合对象set及其操作

#-*-coding:utf-8-*-'''Created on 2016年3月21日@author: Zroad'''"""一、集合对象的特点:1、集合的元素是唯一的2、元素是不可变对象3、集合是无序的""""""二、集合对象的创建:向内置的set函数传递一个序列或是可迭代对象"""x = set('babce') #x= set(['a', 'c', 'b', 'e'])

2016-03-21 23:49:37 553

原创 分数对象Fraction创建、转换及混合运算

#-*-coding:utf-8-*-'''Created on 2016年3月21日@author: Zroad'''from fractions import Fraction"""一、分数对象基础"""#1、创建分数对象x = Fraction(1,3)y = Fraction(4,6)print "x=",x #1/3print "y=",y #2/3 print "t

2016-03-21 23:18:15 919

原创 固定位数和精度的浮点数处理对象Decimal

#-*-coding:utf-8-*-'''Created on 2016年3月20日@author: Zroad'''"""一、Decimal类基础,精准实现小数位数;小数对象就是有固定位数和小数点的浮点数"""#1、浮点数不精确处理的结果print 0.1 + 0.1 + 0.1 - 0.3 #结果不是0,5.55111512313e-17#2、使用小数对象解决浮点数精度问题f

2016-03-20 23:19:56 1108

原创 随机数生成工具random

#-*-coding:utf-8-*-'''Created on 2016年3月20日@author: Zroad'''"""一、生成随机数的工具,random模块"""import random#1、生成0-1间的任意浮点数for i in range(10): print random.random(),print '----------------------'#2、

2016-03-20 22:57:31 349

原创 python常用数学函数

#-*-coding:utf-8-*-'''Created on 2016年3月20日@author: Zroad'''"""一、常见数学常量:pi,e等"""import mathprint "math.pi=",math.piprint "math.e=",math.e"""二、常用数学函数"""print "math.sin(pi)=",math.sin(math.pi)

2016-03-20 12:01:31 351

原创 整数的十进制、二进制、八进制与十六进制

#-*-coding:utf-8-*-'''Created on 2016年3月19日@author: Zroad'''"""一、二进制、八进制、十六进制表示整数常量1.二进制加前缀"0b"2.八进制加前缀"0o"3.十六进制加前缀"0x""""i1 = 0b0001i2 = 0b010010001b1 = 0o001b2 = 0o067c1 = 0x01bfc2 = 0x0

2016-03-20 00:09:15 1435

原创 python除法

#-*-coding:utf-8-*-'''Created on 2016年3月19日@author: Zroad'''#from __future__ import divisionprint "Hello,python3.0""""一、传统除法X/Y形式:1、py2.6:整数相除省去小数部分,浮点数相除保留小数2、py3.0:整数相除也会保留小数部分"""print 3/2

2016-03-19 22:53:44 422

原创 将文件树归档到一个压缩的tar文件中

#-*-coding:utf-8-*-'''Created on 2016年1月25日@author: Zroad'''"""将文件树归档到一个压缩的tar文件中"""import tarfile, osdef make_tar(folder_to_backup, dest_folder, compression='gz'): if compression: d

2016-01-25 23:27:05 435

原创 从zip文件中读取数据

#-*-coding:utf-8-*-'''Created on 2016年1月24日@author: Zroad'''import zipfilez = zipfile.ZipFile("E:\\eclipse-standard-kepler-SR2-win32.zip",'r')for filename in z.namelist(): print "File", filename

2016-01-24 22:27:55 513

原创 设置常量的解决方案

#-*-coding:utf-8-*-'''Created on 2016年1月23日@author: Zroad'''"""常数解决方案:1、一旦定义一个常量后,该常量值不能够修改2、以模块的形式加载到系统"""class _const(object): class ConstError(TypeError): pass def __setattr__(

2016-01-24 22:15:00 378

原创 对象的__dict__属性

#-*-coding:utf-8-*-'''Created on 2016年1月23日@author: Zroad'''class Person(object): def __init__(self,sex,age): self.sex = sex self.age = age def set_height(self,height):

2016-01-23 23:33:55 1029

原创 动态改变python的搜索路径

#-*-coding:utf-8-*-'''Created on 2015年12月28日@author: Zroad'''def add_sys_path(new_path): """ 给sys.path增加一个目录,若此目录不存在或已经在sys.path中,则不操作 返回1表示成功,返回-1表示new_path不存在,0表示已经在sys.path中 """

2015-12-28 23:00:52 338

原创 从指定的搜索路径寻找文件

#-*-coding:utf-8-*-'''Created on 2015年12月28日@author: Zroad'''import osdef search_file(filename, search_path, pathsep=os.pathsep): """ 给定搜索路径,根据请求的名字找到文件 """ for path in search_path.s

2015-12-28 22:41:55 297

原创 生成随机密码

#-*-coding:utf-8-*-'''Created on 2015年12月13日@author: Zroad'''from random import choiceimport stringdef GenPasswd(length=8, chars=string.letters+string.digits): return ''.join([choice(chars) for

2015-12-13 20:50:34 325

原创 通过socket数据报传输消息

#server.py#-*-coding:utf-8-*-'''Created on 2015年12月3日@author: Zroad'''import socketport = 8081s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)s.bind(("",port))print "waiting on port:",portwhil

2015-12-03 22:19:38 364

原创 Tkinter实现带标签的记事本

#-*-coding:utf-8-*-'''Created on 2015年11月30日@author: Zroad'''from Tkinter import *class Notebook(object): def __init__(self, master, side=LEFT): self.active_fr = None self.count =

2015-11-30 23:39:13 1351

原创 Tkinter实现Listbox单行多值

#-*-coding:utf-8-*-'''Created on 2015年11月29日@author: Zroad'''"""Tkinter实现Listbox控件单行多值"""from Tkinter import *class MultiListbox(Frame): def __init__(self,master,lists): Frame.__init__

2015-11-29 22:19:47 4669

原创 Tkinter中使用IDLE的Tree部件

#-*-coding:utf-8-*-'''Created on 2015年11月26日@author: Zroad'''from Tkinter import Tk,Canvasfrom xml.dom.minidom import parseStringfrom idlelib.TreeWidget import TreeItem,TreeNodeprint "Execute here

2015-11-26 23:59:51 918

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除