整理composer安装版本的python脚本

整理composer安装版本的python脚本

脚本实现的功能是去除composer安装命令后的版本号

def remove_version_numbers(commands):
    """
 Remove version numbers from composer require commands.

 Args:
 commands (list of str): List of composer require commands.

 Returns:
 list of str: Commands with version numbers removed.
 """
    cleaned_commands = []
    for command in commands:
        # Split the command by space and remove any part that starts with '^'
        parts = [part for part in command.split() if not part.startswith('^')]
        cleaned_command = ' '.join(parts)
        cleaned_commands.append(cleaned_command)

    return cleaned_commands


def main():
    print("请输入您的 Composer 命令,每行一个。输入 'END' 来结束输入:")
    user_input = []
    while True:
        line = input()
        if line == "END":
            break
        user_input.append(line)

    # 移除版本号
    cleaned_commands = remove_version_numbers(user_input)
    print("\n处理后的命令:")
    for command in cleaned_commands:
        print(command)


if __name__ == "__main__":
    main()

相关推荐

  1. 整理composer安装版本python脚本

    2024-01-05 14:46:06       38 阅读
  2. 如何升级composer版本

    2024-01-05 14:46:06       33 阅读
  3. ubuntu安装特定版本python技巧

    2024-01-05 14:46:06       13 阅读
  4. 【Docker】docker和docker-compose一键安装脚本(linux)

    2024-01-05 14:46:06       17 阅读
  5. ubuntu一键安装docker和docker-compose应用脚本

    2024-01-05 14:46:06       13 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-05 14:46:06       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-05 14:46:06       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-05 14:46:06       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-05 14:46:06       18 阅读

热门阅读

  1. LeetCode 33 搜索旋转排序数组

    2024-01-05 14:46:06       38 阅读
  2. 举例说明自然语言处理(NLP)技术

    2024-01-05 14:46:06       33 阅读
  3. hive问题记录

    2024-01-05 14:46:06       34 阅读
  4. React格式化规范

    2024-01-05 14:46:06       35 阅读
  5. React监听窗口宽度变化 触发resize(Hooks版本)

    2024-01-05 14:46:06       33 阅读
  6. 微信小程序:selectComponent返回null的问题

    2024-01-05 14:46:06       37 阅读
  7. 查询Oracle数据库版本有几种方法

    2024-01-05 14:46:06       39 阅读
  8. 数据库系统原理总结之——数据库系统概述

    2024-01-05 14:46:06       31 阅读
  9. 如何用GPT完成论文高效写作?

    2024-01-05 14:46:06       32 阅读
  10. 编程语言的未来趋势:技术进步中的创新与发展

    2024-01-05 14:46:06       30 阅读