我需要从文件夹中导入json文件作为列表框中的项目,然后再导入组合框。我尝试使用以下方法将文件加载到列表框中:
path_to_json = './'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
self.profiles_print(json_files)
i可以将文件加载到列表框中,但是它们全部作为一项加载在一行上。
如何将其制成单个物品?
谢谢,Dom
您的代码看起来正确,但是我不了解self.profiles_print
的逻辑,这似乎是一个难题,您可以显示代码吗?
从其他来源回答:
path_to_json = './'
json_files = [pos_json for pos_json in os.listdir(path_to_json) if pos_json.endswith('.json')]
for i in json_files:
self.profiles_print(i)