如何检查python文件夹中是否存在.dat文件,如果存在,如何将其与相关的csv匹配?

问题描述 投票:-1回答:1

[我有一个文件夹,每当上传.dat文件时,我都会在其中获得.csv文件。

所以,我想检查特定位置是否存在.dat文件,如果该位置存在,那么我才想使用python和boto3将文件上传到s3。

有人可以帮我吗?

python filepath
1个回答
0
投票

尝试以下操作:

import os

path_to_your_file = ''
if os.path.isfile(path_to_your_file):
    print('File exists')
else:
    print("File doesn't exist")
© www.soinside.com 2019 - 2024. All rights reserved.