def read_text():
#读取文件夹下的文件
folder_path = 'E:\工作相关\数据工厂\综合文本解析\特殊数据优化测试\账单\/test'
file_paths = glob.glob(os.path.join(folder_path, '*'))
for file_path in file_paths:
# 获取文件名
file_name = os.path.basename(file_path)
# 读取文件内容
with open(file_path, 'r') as file:
content = file.read()
data_gbk = content.encode('gbk')
encoded_string=to_base64(data_gbk) #数据base64加密
data=final_data(file_name,encoded_string)# 将数据转变为接口可接受的json格式
result=post_integrationparse(data) #调用post接口,获取接口返回数据
try:
assert "4260" ==result
print(f'File Name: {file_name}' + result) #记录文件名及结果
except AssertionError:
print("AssertionError: Condition is not true")
print(f'File Name: {file_name}' + result)