- 博客(11)
- 收藏
- 关注
原创 前端学习之路
前端学习之路 从今天开始学习前端,到春节之前,做一个计划时间安排工作日中午一小时,晚上一小时;休息日每天晚上两小时;目标今晚定下来,计划看完多少本书,做多少个项目;具体细节待定
2018-01-05 12:45:06
173
原创 ARP协议与ARP攻击
ARP协议定义: 根据IP地址获取物理地址的一个TCP/IP协议。主机发送信息时将包含目标IP地址的ARP请求广播到网络上的所有主机,并接收返回消息,以此确定目标的物理地址;收到返回消息后将该IP地址和物理地址存入本机ARP缓存中并保留一定时间,下次请求时直接查询ARP缓存以节约资源功能:利用ARP缓存表或广播把子网内IP地址转化成物理(MAC)地址。ARP攻击攻击思路:控制子网中一台机器
2017-07-31 13:45:28
331
原创 装饰器@
如果我要对函数进行多次调用,每次调用的参数都不一样,我们可以使用闭包。闭包的特点之一就在于可以实现多样化。如果再扩展一点,实现参数的多样化之外,再实现功能的多样化,就要用到装饰模式的思想。 装饰器模式(Decorator Pattern)允许向一个现有的对象添加新的功能,同时又不改变其结构。这种类型的设计模式属于结构型模式,它是作为现有的类的一个包装。 这种模式创建了一个装饰类,用来包装原
2017-07-14 09:14:30
186
原创 Python的排序功能
sortsort()从大到小排序,覆盖原表。>>> help(list.sort)Help on method_descriptor:sort(...) L.sort(key=None, reverse=False) -> None -- stable sort *IN PLACE*不过盲目用sort会出现一个问题,如果我想要对list排序,但不想破坏原来的list:a = [1,2,3,
2017-07-13 18:58:15
297
转载 python回文
#!/usr/bin/python# -*- coding: UTF-8 -*-def is_palindrome(n): return str(n) == str(n)[::-1]output = filter(is_palindrome, range(1, 100000))print(list(output))转自廖雪峰网站某评论
2017-07-13 17:15:58
280
原创 filter()
def is_odd(n): return n % 2 == 1list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15]))# 结果: [1, 5, 9, 15]fliter()的作用在于定义一个筛选,过滤list。注意fliter()也会生成一个惰性序列,要用list()一步到位。fliter()生成素数序列学习自廖雪峰网站
2017-07-13 16:13:20
270
原创 map()和reduce()的细节
str = "132456741"def str2int(s): def ch2num(s): print("转换字符成功") return{'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s] def num2int(x, y):
2017-07-13 15:09:20
153
原创 HDU 2004
#includeusing namespace std;int main(){ int t = 0; while (cin >> t) { if (t > 100 || t < 0) { cout << "Score is error!" << endl; } else { switch (t / 10) { case 10: case
2017-06-08 11:58:49
239
原创 HDU 2003
#include#include#includeusing namespace std;int main(){ double a = 0; while (cin >> a) { cout << fixed << setprecision(2) << abs(a) << endl; } return 0;}
2017-06-08 11:36:56
193
原创 HDU 2002
#define PI 3.1415927#include #include#includeusing namespace std;int main(void){ double r = 0; while (cin >> r) { cout << fixed << setprecision(3) << pow(r, 3) * PI * 4 / 3 << endl; } re
2017-06-08 11:32:56
196
原创 HDU 2001
#include #include#includeusing namespace std;int main(void){ double x1 = 0, y1 = 0, x2 = 0, y2 = 0; while (cin >> x1 >> y1 >> x2 >> y2) { double x = abs(x1 - x2); double y = abs(y1 - y2);
2017-06-08 11:25:32
174
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人