Python API及相关问题
## jupyterjupyter nbconvert --to python my_file.ipynb## 取整# 向下取整>>> a = 14.38>>> int(a)14# 向上取整>>> import math>>> math.ceil(3.33)4>>> math.ceil(3.88)4# 四舍五入>>> round(4.4)4>>> round(4.6)5## python3调用c函数接口的错误# python2的源码直接在python3.7运行(出错):net = dn.load_net("cfg/yolov3.cfg", "weights/yolov3.weights", 0)ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type## python3默认编码与python不一样, utf8转换:net = dn.load_net("cfg/yolov3.cfg".encode("utf-8"), "weights/yolov3.weights".encode("utf-8"), 0)import os.path as opsos.path.abspath(path) # 返回绝对路径os.path.expanduser(path) # 把path中包含的"~"和"~user"转换成用户目录os.path.basename(path) # 返回文件名