[英]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.