我想做这样的事情,但对于 Django 管理命令: Python argparse: How to insert newline in the help text?
最佳答案
You can customize the instance by overriding this method and calling super() with kwargs of ArgumentParser parameters.
通过覆盖 create_parser
方法
您可以设置 ArgumentParser
的 formatter_class
:
from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def create_parser(self, *args, **kwargs):
parser = super(Command, self).create_parser(*args, **kwargs)
parser.formatter_class = RawTextHelpFormatter
return parser
关于python - Django 命令 : How to insert newline in the help text?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35470680/