坚持为自己每月写1篇笔记

Retreat Hell!
We Just Got Here.

Python面试题之一:解密

Python面试题之一:
说明:就是Python工程师面试题

一.字典转换与正则提取值

1:key与Value交换

a = {'a':1,'b':2}
print({value:key for key, value in a.items()})

2:正则筛选【2017-01-01 13:12:12】有关数据

import re

with open("data.log", "r", encoding="utf-8") as f:
    data = re.compile(r'2018-10-16 17:50:53 .*\S{2}')
    print(data.findall(f.read()))

 

二.Python调C/C++

答案:

import ctypes
run = ctypes.cdll.LoadLibrary
lib = run("model.so") #指定gcc编译生成动态库路径 /root/user/python_code
lib.HelloWorld()
print('***finish***')

 

 

 

posted @ 2018-10-16 18:20  l||||||l  阅读(353)  评论(0编辑  收藏  举报