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***')