defremove_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() ifnot part.startswith('^')] cleaned_command = ' '.join(parts) cleaned_commands.append(cleaned_command)
return cleaned_commands
defmain(): print("请输入您的 Composer 命令,每行一个。输入 'END' 来结束输入:") user_input = [] whileTrue: 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)