python - 如何在 cython 结构中创建日期时间字段?字符串字段怎么样?
问题描述
如何在 cython 结构中创建日期时间字段:
cdef struct Purchase:
int purchase_id
datetime purchase_timestamp
str free_text
我应该用什么来表示上面的“日期时间”标识符?
字符串呢?我可以只使用“char *”吗?有更灵活的东西吗?如果我删除 Purchase 类的一个实例,我是否需要进行任何内存清理?
谢谢!
解决方案
from cpython.datetime cimport datetime
cdef class Purchase:
cdef int purchase_id
cdef datetime timestamp
cdef str free_text
推荐阅读
- keras - 为什么我有三个不同的 MSE 值
- go - MagickWand 7 API:如何移植 MagickSetImageClipMask 调用
- computational-geometry - CGAL 坐标值转换在 5.2.1 中不再起作用
- reactjs - 无法在类组件中调用 React Hook “React.useState”
- pyopencl - 子类 pyopencl.array.Array
- c# - 虚幻引擎构建在 C# 尝试打开回收站文件时崩溃
- python - 如何将一些字符串更改为字典中的整数?
- heroku - 尝试将应用程序部署到 Heroku 时出现错误代码=H10
- python - Plotly:如何使用plotly express结合散点图和折线图,使散点图和折线图都随着动画帧的变化而变化?
- python - 如何从推文中提取点赞数?