如果open()方法中的路径只是一个文件名,它指向的默认目录是什么?
def write_dicts_to_file(path,data):
with open(path,'wb') as fp:
for d in data:
fp.write(json.dumps(d).encode('utf-8'))
fp.write("\n".encode('utf-8'))
write_dicts_to_file("train.json",training_data)
答案 0 :(得分:0)
您从中调用write_dicts_to_file()
方法的python文件的目录。