我想解析多個文本文件中的某些段落並將它們存儲在列表中。所有文本文件有一定的格式類似於這樣: MODEL NUMBER: A123
MODEL INFORMATION: some info about the model
DESCRIPTION: This will be a description of the Model. It
could be multiple lines but
dir(object)返回對象屬性和函數的列表。我如何迭代所有可調用函數並獲得函數的輸出? (假定沒有功能ARGS) for a in dir(obj) if not a.startswith('__') and callable(getattr(obj,a)):
response = obj.a()
這不起作用,因爲python將a視爲屬性名稱。有沒有辦法做到這一點?