整理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_commandsdef main():print("请输入您的 Composer 命令,每行一个。输入 'END' 来结束输入:")user_input = []while True:line = input()if line == "END":breakuser_input.append(line)# 移除版本号cleaned_commands = remove_version_numbers(user_input)print("\n处理后的命令:")for command in cleaned_commands:print(command)if __name__ == "__main__":main()