您可以使用Python的os和shutil模块来实现自动寻找并上传文件到服务器。以下是一个示例代码:

import os
import shutil

# 遍历目录,寻找后缀为txt和zip的文件
def find_files(directory):
    file_list = []
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith(".txt") or file.endswith(".zip"):
                file_list.append(os.path.join(root, file))
    return file_list

# 上传文件到服务器
def upload_file(file_path, server_path):
    shutil.copy(file_path, server_path)

# 主程序
if __name__ == "__main__":
    directory = "/path/to/directory"  # 替换为要搜索的目录
    server_path = "/path/to/server"  # 替换为服务器的路径

    file_list = find_files(directory)
    for file in file_list:
        upload_file(file, server_path)

请注意,您需要将/path/to/directory替换为要搜索的目录的实际路径,将/path/to/server替换为服务器的实际路径。此外,您可能还需要根据您的服务器设置进行相应的文件上传操作

用代码写自动寻找后缀带有txtzip的文件然后上传服务器

原文地址: https://www.cveoy.top/t/topic/iWZG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录