以下是一个简单的Python脚本中心示例:

import os

print("Welcome to the Script Center!")

while True:
    # 显示可用脚本
    print("\nAvailable Scripts:")
    scripts = os.listdir("scripts")
    for i, script in enumerate(scripts):
        print(f"{i+1}. {script}")

    # 提示用户选择脚本
    choice = input("\nPlease enter the number of the script you want to run (or 'q' to quit): ")
    if choice.lower() == 'q':
        break
    try:
        choice = int(choice)
        script = scripts[choice-1]
        # 运行脚本
        os.system(f"python scripts/{script}")
    except (ValueError, IndexError):
        print("Invalid choice. Please try again.")

该脚本假设所有可用脚本都位于名为“scripts”的文件夹中。它使用Python的os模块列出所有可用脚本,并提示用户选择要运行的脚本。一旦用户做出选择,它将使用os.system()函数运行选定的脚本。

要使用此脚本中心,请将所有可用脚本放入名为“scripts”的文件夹中,并运行此脚本

用python做一个脚本中心

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

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