- 博客(21)
- 收藏
- 关注
转载 python装饰器小例子
import timedef timer(func): #timer(test1) func=test1 def deco(*args,**kwargs): start_time=time.time() func(*args,**kwargs) stop_time=time.time() print("the func r...
2017-07-02 21:13:00
147
转载 递归返回指定文件夹中文件的路径,以及其包含文件夹中文件的路径
import osdef print_directory_contents(sPath): for sChild in os.listdir(sPath): sChildPath = os.path.join(sPath,sChild) if os.path.isdir(sChildPath): print_directory_co...
2017-07-02 20:39:00
227
转载 分别使用shell和python实现两列排序
有一个文件1.txt如下,要求使用shell和python实现排序,先按照第一列排序,第一列相同再按照第二列排序,并且输出到另外一个文件2.txtLZdeMacBook-Pro:~ lz$ cat 1.txt23 d26 t12 y43 h5 k12 ashell实现:LZdeMacBook-Pro:~ lz$ sort -k1,1n -k2,2 1...
2017-06-28 11:19:00
321
转载 python 实现二叉树 求二叉树的叶子节点个数
#coding=utf-8class Node(object): """节点类""" def __init__(self, elem=-1, lchild=None, rchild=None): self.elem = elem self.lchild = lchild self.rchild = rchildclass Tree...
2017-06-22 18:27:00
1671
转载 python小程序2个
1、递归求1-100的和def sumA(fin): if fin==0: return 0 else: return fin+sumA(fin-1)print sumA(100)2、将一个字符串中h字母去掉输出之后的字符串str1 = 'abcdefghijklmnopqh123'str2 = []for i in range(0,le...
2017-05-11 18:23:00
100
转载 python实现简单爬虫程序
#coding=utf-8import reimport urllibdef getHtml(url): page = urllib.urlopen(url) html = page.read() return htmldef getImg(html): reg = r'src="(.*?\.jpg)" pic_ext' imgr...
2017-04-26 15:51:00
135
转载 包回放介绍
本文主要介绍Linux下三种包回放的适用场景:tomahawk、tcpreplaytomahawk是一款基于Linux系统,用于测试入侵防御系统(IPS)的工具,工作在OSI模型的第二层,只能测试网桥型网络设备。tomahawk工作在有三个网卡的机器上:一个用来管理,另外两个用来测试。我们可以使用tomahawk回放各种数据包,产生背景流量、大量的连接、模块稳定性、系统稳定性与模拟客...
2017-03-21 15:30:00
627
转载 [linux系统]查看内核版本和系统版本方法
查看内核版本信息的两个命令:uname -acat /proc/version查看系统版本的命令:lsb_release -amore /etc/issuecat /etc/redhat-releaserpm -qredhat-release (只适用于redhat)转载于:https://www.cnblogs.com/joangaga/p/624...
2017-01-04 17:25:00
106
转载 [Linux系统]查看内存的几种方式
1、 cat /proc/meminfo 2、free -m3、vmstat -s4、ps命令可以实时的显示各个进程的内存使用情况。Reported memory usage information includes %MEM (percent of physical memory used), VSZ (total amount of virtual memory used), and...
2016-12-14 16:06:00
150
转载 [linux系统]--搭建ftp服务器并且 创建用户 设置密码
下面例子演示创建ftpuser 并且设置密码为ftpuser,ftpuser的目录为/root/ftpuser#!/bin/bashrpm -ivh vsftpd-2.2.2-21.el6.x86_64.rpmusername=ftpuseruseradd -d /root/$username $username echo "$username"|passwd --stdin $...
2016-09-19 20:09:00
585
转载 [linux系统]--spawn 用法
spawn与except组合可达到远程登录设备执行命令的作用下面是登录设备的一段代码#!/usr/bin/expect -fuser=roothost=1.1.1.1password=rootspawn $user@$hostset timeout 60except { "(yes/no)?" { send "yes\n" ...
2016-09-19 20:01:00
1756
转载 wireshark常用过滤条件
抓取指定IP地址的数据流:如果你的抓包环境下有很多主机正在通讯,可以考虑使用所观察主机的IP地址来进行过滤。以下为IP地址抓包过滤示例:host 10.3.1.1:抓取发到/来自10.3.1.1的数据流host 2406:da00:ff00::6b16:f02d:抓取发到/来自IPv6地址2406:da00:ff00::6b16:f02d的数据流not host...
2016-09-19 10:06:00
1407
转载 [linux系统]--crontab定时任务
基本格式 :* * * * * command分 时 日 月 周 命令第1列表示分钟1~59 每分钟用*或者 */1表示第2列表示小时1~23(0表示0点)第3列表示日期1~31第4列表示月份1~12第5列标识号星期0~6(0表示星期天)第6列要运行的命令crontab文件的一些例子:30 21 * * * /usr/local/etc/rc.d/...
2016-09-12 17:24:00
380
转载 [linux系统]--常用命令
1、shell实现找到当前目录以及子目录中名字包含king的文件find ./ | grep king2、tcpdump抓包参数 -nne分别代表什么意思-nn:直接以 IP 及 port number 显示,而非主机名称服务和名称-e : 每行的打印输出中将包括数据包的数据链路层头部信息3、一个大文件查找关键字所在的行并打印这一行sed -n '/key/p' ...
2016-08-31 20:16:00
131
转载 python 列表排序
转自http://www.iplaypython.com/jinjie/jj114.htmlreverse()方法将列表中元素反转排序,比如下面这样>>> x = [1,5,2,3,4]>>> x.reverse()>>> x[4, 3, 2, 5, 1]reverse列表反转排序:是把原列表中的元素顺序从左至右的重新存放,而...
2016-08-12 17:48:00
460
转载 python实现排序算法
冒泡排序importrandomdefBubbleSort(num):n=len(num)foriinrange(0,n):forjinrange(i,n):ifnum[i]>=num[j]:num[i],num[j]=num[j],num[i]returnnu...
2016-08-12 09:46:00
101
转载 ftp协议详解
客户端与服务器之间,需要多条连接才能完成应用的协议,属于复杂协议。如FTP,PPTP,H.323和SIP均属于复杂协议。这里主要介绍ftp协议的工作原理。首先,ftp通信协议有两种工作模式,被动模式和主动模式。主动模式 以上图为例,假设客户端IP为192.168.2.10,服务器端IP为192.168.2.11,首先客户端使用端口1966连接服务器的21端口...
2016-08-08 18:20:00
188
转载 [linux系统]--Sed
删除:d命令$ sed ‘2d’ example—–删除example文件的第二行。$ sed ‘2,$d’ example—–删除example文件的第二行到末尾所有行。$ sed ‘$d’ example—–删除example文件的最后一行。$ sed ‘/test/’d example—–删除example文件所有包含test的行。替换:s命令...
2016-08-08 17:58:00
105
转载 清除dns缓存
Linux清除dns缓存命令 /etc/init.d/dnsmasq restart转载于:https://www.cnblogs.com/joangaga/p/5750424.html
2016-08-08 17:53:00
152
转载 打开网页会有那些操作
域名解析 --> 发起TCP的3次握手 --> 建立TCP连接后发起http请求 --> 服务器响应http请求,浏览器得到html代码 --> 浏览器解析html代码,并请求html代码中的资源(如js、css、图片等) --> 浏览器对页面进行渲染呈现给用户转载于:https://www.cnblogs.com/joangaga/p/57503...
2016-08-08 17:49:00
151
转载 HTTP状态码
1xx - 信息提示这些状态代码表示临时的响应。客户端在收到常规响应之前,应准备接收一个或多个 1xx 响应。· 100 - Continue 初始的请求已经接受,客户应当继续发送请求的其余部分。(HTTP 1.1新)· 101 - Switching Protocols 服务器将遵从客户的请求转换到另外一种协议(HTTP 1.1新)2xx - 成功...
2016-08-08 17:49:00
87
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人