import osimport os.pathdef unify_ext_with_os_path(path):"""The .txt file name suffix in the unified directory is .csv"""for filename in os.listdir(path):basename, ext = os.path.splitext(filename)if ext == '.txt':abs_filepath = os.path.join(path, filename)os.rename(abs_filepath, os.path.join(path, f'{basename}.csv'))
for filename in os.listdir(path):
basename, ext = os.path.splitext(filename)
Reference documentpython gets the file name without a suffix_Use Python to efficiently manipulate files, 3 super practical suggestions to share with you..._weixin_39605997's blog-CSDN blog