如何在 Python 2.6 中获得 argparse? [英] How can I get argparse in Python 2.6?

查看:22
本文介绍了如何在 Python 2.6 中获得 argparse?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一些使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆