摘要: 1.简单的将日志打印到屏幕import logginglogging.debug('This is debug message')logging.info('This is info message')logging.warning('This is warning message')屏幕上打印:WARNING:root:This is warning message默认情况下,logging将日志打印到屏幕,日志级别为WARNING;日志级别大小关系为:CRITICAL > ERROR > WARNING > INFO > 阅读全文
posted @ 2011-10-21 19:38 方倍工作室 阅读(5848) 评论(0) 推荐(0)
摘要: #-*- coding: UTF-8 -*- import urllib2, re,datetime,time, os,sys from PIL import Image, ImageDraw, ImageFont from math import atan, degrees # #图片下载类 #功能:下载图片,生成缩略图,生成水印图 # class dow... 阅读全文
posted @ 2011-10-19 19:30 方倍工作室 阅读(585) 评论(0) 推荐(0)
摘要: # -*- coding: utf-8 -*-"""some function by metaphy,2007-04-03,copyleftversion 0.2"""import urllib, httplib, urlparseimport reimport random"""judge url exists or not,by others"""def httpExists(url): ... 阅读全文
posted @ 2011-10-19 19:29 方倍工作室 阅读(1270) 评论(0) 推荐(0)
摘要: python中对文件、文件夹的操作需要涉及到os模块和shutil模块。 创建文件: 1) os.mknod("test.txt") 创建空文件 2) open("test.txt",w) 直接打开一个文件,如果文件不存在则创建文件 创建目录: os.mkdir("file") 创建目录 复制文件... 阅读全文
posted @ 2011-10-19 19:27 方倍工作室 阅读(311) 评论(0) 推荐(0)
摘要: 1. 显示当前日期:1 #! /usr/bin/env python2 #coding=utf-83 4 import time5 6 print time.strftime('%Y-%m-%d %A %X %Z',time.localtime(time.time()))或者1 #! /usr/bin/env python2 #coding=utf-83 4 import time5 6 print time.time()7 8 print time.strftime("%Y-%m-%d %A %X %Z", time.localtime())你也可以用: 阅读全文
posted @ 2011-10-18 12:25 方倍工作室 阅读(4832) 评论(0) 推荐(0)
摘要: 正则表达式30分钟入门教程版本:v2.32 (2011-8-17) 作者:deerchao 转载请注明来源目录跳过目录本文目标如何使用本教程正则表达式到底是什么东西?入门测试正则表达式元字符字符转义重复字符类分枝条件反义分组后向引用零宽断言负向零宽断言注释贪婪与懒惰处理选项平衡组/递归匹配还有些什么东西没提到联系作者网上的资源及本文参考文献更新纪录本文目标30分钟内让你明白正则表达式是什么,并对它有一些基本的了解,让你可以在自己的程序或网页里使用它。如何使用本教程最重要的是——请给我30分钟,如果你没有使用正则表达式的经验,请不要试图在30秒内入门——除非你是超人 :)别被下面那些复杂的表达式 阅读全文
posted @ 2011-10-17 16:37 方倍工作室 阅读(643) 评论(0) 推荐(0)
摘要: 一些常见的状态码为: 200 – 服务器成功返回网页 404 – 请求的网页不存在 503 – 服务不可用 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码。 代码 说明 100 (继续) 请求者应当继续提出请求。 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分。 101 (切换协议) 请求者已要求服务器切换协议,服务器已确认并准备切换。 2xx (成功) 表示成功处... 阅读全文
posted @ 2011-10-17 09:42 方倍工作室 阅读(746) 评论(0) 推荐(0)
摘要: 在python有各种各样的string操作函数。在历史上string类在python中经历了一段轮回的历史。在最开始的时候,python有一个专门的string的module,要使用string的方法要先import,但后来由于众多的python使用者的建议,从python2.0开始, string方法改为用S.method()的形式调用,只要S是一个字符串对象就可以这样使用,而不用import。同时为了保持向后兼容,现在的 python中仍然保留了一个string的module,其中定义的方法与S.method()是相同的,这些方法都最后都指向了用S.method ()调用的函数。要注意,S 阅读全文
posted @ 2011-10-16 14:24 方倍工作室 阅读(555) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\homework03.tcl 2: 3: #Create a simulator object 4: set ns [new Simulator] 5: 6: #Define different colors for data flows 7: $ns color 1 Blue 8: $ns color 2 Red 9: 10: #Open the nam trace file 11: set nf [open szsh.nam w] 12: $ns namtrace-all $nf 13: 14: #Open the trace reco... 阅读全文
posted @ 2011-10-13 12:44 方倍工作室 阅读(286) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\homework02.tcl 2: 3: #Create a simulator object 4: set ns [new Simulator] 5: 6: #Define different colors for data flows 7: $ns color 1 Blue 8: $ns color 2 Red 9: 10: #Open the nam trace file 11: set nf [open szsh.nam w] 12: $ns namtrace-all $nf 13: 14: #Open the trace reco... 阅读全文
posted @ 2011-10-13 12:38 方倍工作室 阅读(351) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\homework01.tcl 2: 3: #创建两个结点,深圳到北京的TCP连接,图形将数据显示出来,计算吞吐率,画图分析 4: #tcp上层用ftp 5: #udp上层用cbr 6: #Create a simulator object 7: set ns [new Simulator] 8: 9: set nf [open SZ2BJ.nam w] 10: $ns namtrace-all $nf 11: 12: set nd [open SZ2BJ.tr w] 13: $ns namtrace-all $nd 14: 15: proc... 阅读全文
posted @ 2011-10-13 12:37 方倍工作室 阅读(306) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\ForGnuplot.plot 2: 3: #gnuplot> 4: #set xtics 0, 1, 10 5: set grid 6: set xrange [0:10] 7: set yrange [0:1000] 8: set key top left set key bottom right 9: set key box 10: set title "TCP Throughput" 11: set xlabel "Time(s)" 12: set ylabel "Throughput(kb)" 阅读全文
posted @ 2011-10-13 12:35 方倍工作室 阅读(407) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\Throughput.awk 2: 3: BEGIN { 4: #Initialize the variable 5: init = 0; 6: i = 0; 7: } 8: 9: { 10: #Event Abbreviation Type Value 11: #%g %d %d %s %d %s %d %d.%d %d.%d %d %d 12: #Normal Event 13: #r: Receive 14: #d: Drop 15: #e: Error 16: ... 阅读全文
posted @ 2011-10-13 12:34 方倍工作室 阅读(357) 评论(0) 推荐(0)
摘要: 1: #NS2_有线部分\LossRate.awk 2: 3: BEGIN { 4: #Initialize the variable 5: Lost = 0; #the Sum of Lost packet 6: Send = 0; #the Sum of Send packet 7: } 8: 9: { 10: #Event Abbreviation Type Value 11: #%g %d %d %s %d %s %d %d.%d %d.%d %d %d 12: #Normal Event 13: #r... 阅读全文
posted @ 2011-10-13 12:33 方倍工作室 阅读(1175) 评论(0) 推荐(0)
摘要: 关键字:WinPcap 网卡 MAC地址作者:txw1958在WpdPack_4_1_2\WpdPack\Examples-remote\PacketDriver\GetMacAddress\目录下有获取MAC地址源文件GetMacAddress.c 1: /* 2: * Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy) 3: * Copyright (c) 2005 - 2006 CACE Technologies, Davis (California) 4: * All rights re... 阅读全文
posted @ 2011-10-13 12:32 方倍工作室 阅读(8459) 评论(1) 推荐(0)
摘要: 1: #NS2_有线部分\EndDelay.awk 2: 3: BEGIN { 4: #Initialize the variable 5: MaxID = 0; 6: i = 0; 7: } 8: 9: { 10: #Event Abbreviation Type Value 11: #%g %d %d %s %d %s %d %d.%d %d.%d %d %d 12: #Normal Event 13: #r: Receive 14: #d: Drop 15: #e: Error 16: ... 阅读全文
posted @ 2011-10-13 12:31 方倍工作室 阅读(860) 评论(0) 推荐(0)
摘要: 关键字:IP地址 正则表达式作者:txw1958出处:http://www.cnblogs.com/txw1958/archive/2011/10/13/ip_address_regular_expression.html IP地址的长度为32位,分为4段,每段8位,用十进制数字表示,每段数字范围为 阅读全文
posted @ 2011-10-13 12:30 方倍工作室 阅读(131632) 评论(19) 推荐(4)
摘要: 1: echo %time% 2: 3: 4: rem ** ipc and mapping 5: c: 6: net use x: /del 7: net use y: /del 8: net use \\10.11.44.1\ipc$ /del 9: echo ============================================== 10: net ... 阅读全文
posted @ 2011-10-13 12:28 方倍工作室 阅读(259) 评论(0) 推荐(0)
摘要: 第二十二章、 其它应用 1) Web服务 ##代码 s 000063.SZ ##开盘 o 26.60 ##最高 h 27.05 ##最低 g 26.52 ##最新 l1 26.66 ##涨跌 c1 -0.04 ##涨幅 p2 -0.15% ##总手 v 9190865 ##日期 d1 6/15/2011 ##时间 t1 3:00am #!/usr/bin/env python from time import ctime from urllib import urlopen import re ti... 阅读全文
posted @ 2011-10-13 12:28 方倍工作室 阅读(969) 评论(0) 推荐(0)
摘要: 1: rem "D:\Microsoft Visual Studio 8\SDK\v2.0\Bin\sdkvars.bat" 2: D: 3: cd ..\..\..\..\..\..\..\..\..\..\..\..\ 4: cd "D:\Microsoft Visual Studio 8\SDK\v2.0\Bin" 5: 6: @Set Path=D:\Micros... 阅读全文
posted @ 2011-10-13 12:27 方倍工作室 阅读(310) 评论(0) 推荐(0)
摘要: 第二十一章、 扩展Python /* D:\Python27\Lib\Extest-1.0\Extest2.c */ #include <stdio.h>#include <stdlib.h>#include <string.h> #include "Python.h" int fac(int n){ if (n < 2) return(1); return (n)*fac(n-1);} static PyObject *Extest_fac(PyObject *self, PyObject *args){ int num; if 阅读全文
posted @ 2011-10-13 12:27 方倍工作室 阅读(322) 评论(0) 推荐(0)
摘要: 第二十章、 数据库编程 环境设置 1).安装MySQL-python http://www.lfd.uci.edu/~gohlke/pythonlibs/ MySQL-python-1.2.3.win32-py2.7.exe 1) 使用数据库接口 import MySQLdb cxn = MySQLdb.Connect(host = '127.0.0.1', user = 'root', passwd = 'root') cur = cxn.cursor() try: cur.execute("DROP DATABASE test610 阅读全文
posted @ 2011-10-13 12:26 方倍工作室 阅读(533) 评论(0) 推荐(0)
摘要: 1: subst t: /d 2: subst t: D:\PublicViews\Automation_Framework\SQA_ATE_DEV 3: 4: rem ** update folders 5: t: 6: cd ..\..\..\..\..\..\..\..\..\..\..\..\ 7: 8: rmdir /s /q "t:\_updated_jimm... 阅读全文
posted @ 2011-10-13 12:25 方倍工作室 阅读(285) 评论(0) 推荐(0)
摘要: 第十九章、 图形界面编程 import Tkintertop = Tkinter.Tk() hello = Tkinter.Label(top, text='Hello World!')hello.pack()quit = Tkinter.Button(top, text='QUIT',command=top.quit)quit.pack(fill=Tkinter.X, expand=1) Tkinter.mainloop() 阅读全文
posted @ 2011-10-13 12:23 方倍工作室 阅读(339) 评论(0) 推荐(0)
摘要: 第十八章、 Web编程 import urllib2 LOGIN = 'jin'PASSWD = 'Welcome'URL = 'https://tlv-tools-qc:8443/qcbin/start_a.htm'def handler_version(url): from urlparse import urlparse as up hdlr = urllib2.HTTPBasicAuthHandler() hdlr.add_password('Archives', up(url)[1], LOGIN, PASSWD) op 阅读全文
posted @ 2011-10-13 12:22 方倍工作室 阅读(462) 评论(0) 推荐(0)