将表格数据存储在 Class 中

Store tabular data in Class

在我的 class 定义中,是否有任何标准和 pythonic 方法来存储一个小的 table(由几行和几列组成)常量值作为字段?

我想知道在 class 定义中定义这样一个 table 的默认值是标准的,还是建议在其他地方定义它。

事实上,根据某些用户输入,我想使用此 table 的某行作为默认值来实例化我的 class.

你在这里有很多可能性,你可以使用多维lists(列表中的列表)或numpy arrayshttps://numpy.org/doc/stable/reference/generated/numpy.array.html) or pandas dataframes (https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html)。

Pandas dataframe 附带了很多表格数据的功能,因此请查看它们的文档并考虑它是否适合您。