file = './test_data'
files = os.listdir(file)
for fileName in files:
print(fileName)
for key,name in enumerate(files):
print(key, name)
test1.jpg
test2.jpg
test.png
0 test1.jpg
1 test2.jpg
2 test.png
import os
# 判断文件
os.path.exists('./app.py')
# 判断文件夹
# os.path.exists('test_data')
import json
out_file = f'./高管股东-增持.json'
with open(out_file, 'r', encoding='utf8') as fp:
json_data = json.load(fp)
print(json_data)
import json
data = { 'a': '1' }
out_file = f'./高管股东-增持.json'
json.dump(data, open(out_file, 'w'), indent=4)