第一次在segmentfault发帖,也是没办法,才希望能够得到帮助。
问题也许很低端,但是,我尝试了一个礼拜了,都没有找到好的解决方法。。。请各位大神帮帮忙
问题描述
希望做到用python来输出一份dbf格式的文件。
于是乎,我百度到了这一份python2的代码,可以工作
#!/usr/bin/python
# -*- coding: utf-8 -*-
import struct
import datetime
import decimal
import itertools
def dbfwriter(f, fieldnames, fieldspecs, records):
""" Return a string suitable for writing directly to a binary dbf file.
File f should be open for writing in a binary mode.
Fieldnames should be no longer than ten characters and not include \x00.
Fieldspecs are in the form (type, size, deci) where
type is one of:
C for ascii character data
M for ascii character memo data (real memo fields not supported)
D for datetime objects
N for ints or decimal objects
L for logic