[英]How do I open multiple .json files at once that contain test cases?
這是適用於一個 json 文件的示例代碼。 我需要加載信用。json,住房P.json,心情。json,攪動。Z466DEEC76ECDF25FCA6D3857D54里面的testSplited6文件夾。
def load_test_params():
with open(filePath + '/testsSplited/churn.json') as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
TEST_PARAMS = load_test_params()
最好使用以下 pandas 技巧
import pandas as pd
if __name__ == "__main__":
df = pd.read_json (r'sequencesHost.json')
這是適用於一個 json 文件的示例代碼。 我需要加載信用。json,住房P.json,心情。json,攪動。Z466DEEC76ECDF25FCA6D3857D54里面的testSplited6文件夾。
def load_test_params():
with open(filePath + '/testsSplited/churn.json') as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
TEST_PARAMS = load_test_params()
這使用 for 循環
def load_test_params():
json_path = filePath + '/testsSplited/'
json_list = [f for f in os.listdir(filePath + '/testsSplited/') if f.endswith('.json')]
for i in json_list:
with open(filePath + '/testsSplited/'+ i) as json_file:
data = json.load(json_file)
assert len(data['tests']) > 0
test_params = data['tests']
return test_params
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.