如何在Python 2.6中获取argparse? [英] How can I get argparse in Python 2.6?
问题描述
我编写了一些使用argparse模块的Python 2.7代码.现在,我需要在Python 2.6机器上运行它,因为argparse是在2.7中添加的,所以它将无法运行.
I have some Python 2.7 code written that uses the argparse module. Now I need to run it on a Python 2.6 machine and it won't work since argparse was added in 2.7.
反正我可以在2.6中获得argparse吗?我想避免重写代码,因为我经常在机器之间传输这种代码.不能升级python.
Is there anyway I can get argparse in 2.6? I would like to avoid rewriting the code, since I will be transferring this kind of code between the machines often. Upgrading python is not an option.
我应该澄清,理想的解决方案是不需要模块安装的解决方案.
I should have clarified that the ideal solution would be something that does not require module installation.
推荐答案
您可以通过pip或easy_install进行安装: https://pypi.python.org/pypi/argparse
You can install it via pip or easy_install: https://pypi.python.org/pypi/argparse
这篇关于如何在Python 2.6中获取argparse?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!