我不知道有任何库可以从python数据结构输出RST,但是您自己格式化它很容易。这是将python元组列表格式化为RST表的示例:
>>> data = [('hey', 'stuff', '3'), ('table', 'row', 'something'), ('xy', 'z', 'abc')]>>> numcolumns = len(data[0])>>> colsizes = [max(len(r[i]) for r in data) for i in range(numcolumns)]>>> formatter = ' '.join('{:<%d}' % c for c in colsizes)>>> rowsformatted = [formatter.format(*row) for row in data]>>> header = formatter.format(*['=' * c for c in colsizes])>>> output = header + 'n' + 'n'.join(rowsformatted) + 'n' + header>>> print output===== ===== =========hey stuff 3 table row somethingxy z abc ===== ===== =========


