2019.07.08
这一阵每周都会有几天早到公司一小时,所以会自己学习或者复习一下,以后争取每天将自己学习的东西记录一下。
计算机指令
不同的CPU有不同的指令集。
高级语言如果需要被执行,首先会被编译成汇编语言,然后再通过汇编器编译成机器码。
在linux系统上可以通过以下指令查看一个程序的汇编码和指令码:
$ gcc -g -c test.c
$ objdump -d -M intel -S test.o
指令集一般分为五大类:
1、算术指令集,例如加减乘除。
2、数据传输类指令集,例如变量赋值、在内存里读写数据。
3、逻辑类指令,例如与或非。
4、条件分类指令,例如‘if/else’
5、无条件跳转指令,例如函数或者方法。
Python正则表达式
re.match() 是从开头进行匹配
re.search() 是从任意位置进行匹配
group() 方法访问每个独立的子组以,groups() 方法以获取一个包含所有匹配子组的元组。
>>> m = re.match('ab', 'ab')
>>> m.group()
'ab'
>>> m.groups()
()
>>> m = re.match('(a)(b)', 'ab')
>>> m.group()
'ab'
>>> m.group(1)
'a'
>>> m.group(2)
'b'
>>> m.groups()
('a', 'b')
\b是匹配一个字符串在边界,\B是不在边界
>>> m = re.search(r'\bthe', 'bite the dog') #在边界
>>> if m is not None: m.group()
...
'the'
>>> m = re.search(r'\bthe', 'bitethe dog') #有边界
>>> if m is not None: m.group()
...
>>> m = re.search(r'\Bthe', 'bitethe dog') #没有边界
>>> if m is not None: m.group()
...
'the'
re.findall() 返回一个包含所有成功匹配部分的列表,如果没有找到匹配的部分就返回一个空列表。
>>> re.findall('car', 'carry the barcardi to the car')
['car', 'car', 'car']
re.finditer() 返回的是一个迭代器。
>>> s = 'This and that'
>>> [g.group(1) for g in re.finditer(r'(th\w+)', s, re.I)]
['This', 'that']