Windows下常用命令

常用命令

查看基本信息

命令 功能
winver 系统信息
gpedit.msc –组策略
regedit.exe -注册表
eventvwr 事件查看器
lusrmgr.msc 用户组查看器
services.msc 本地服务设置
devmgmt.msc 设备管理器
compmgmt.msc 计算机管理
diskmgmt.msc 磁盘管理实用程序
阅读全文
python下的各种器

生成器(generator)

在Python中,这种一边循环一边计算的机制,称为生成器:generator,generator保存的是算法

创建 generator:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 方法一 : 
>>> g = (x * x for x in range(5))
>>> g
>>> <generator object <genexpr> at 0x1022ef630>
>>> >>> next(g)
0
>>> next(g)
1
>>> next(g)
4
>>> next(g)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
StopIteration
## 为避免报错 建议使用for循环
-------------------------
# 方法二 yield: 如果一个函数定义中包含yield关键字,那么这个函数就不再是一个普通函数,而是一个generator,yield为下次继续在该位置继续执行

# 以斐波那契数列为例子
def fib(max):
n, a, b = 0, 0, 1
while n < max:
yield b
a, b = b, a + b
n = n + 1
return 'done'
# yield为下次继续在该位置继续执行
阅读全文
python数据类型运用

Python共有8种数据类型

类型 备注
Number(数字) 不可变值
String(字符串) 不可变值
Boolean(布尔值) 不可变值
None(空值) 不可变值
List(列表) 可变值
Tuple(元组) 不可变值
dict(字典) 可变值
set(集合) 可变值
阅读全文
python高级函数运用总结

map

map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的Iterator返回

1
2
3
4
5
6
7
8
9
10
11
>>> def f(x):
... return x * x
...
>>> r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> list(r)
[1, 4, 9, 16, 25, 36, 49, 64, 81]

------

>>> list(map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]))
['1', '2', '3', '4', '5', '6', '7', '8', '9']

阅读全文
python下装饰器的详解

装饰器简介


实质: 是一个函数
参数:是你要装饰的函数名(并非函数调用)
返回:是装饰完的函数名(也非函数调用)
作用:为已经存在的对象添加额外的功能
特点:不需要对对象做任何的代码上的变动
应用场景:插入日志、性能测试、事务处理、权限校验等


简单用法如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# *arg,**kw 表示所有任意参数
def test(func):
def printname(*arg,**kw):
print('this is 装饰器')
return func(*arg,**kw)
return printname

@test
def ceshi():
print('我是ceshi函数')

ceshi()

>>>>
this is 装饰器
我是ceshi函数

阅读全文
Algolia