示例脚本:
import os
import sys
from pprint import pprint
import yaml
sys.path.append(os.path.realpath("."))
import inquirer # noqa
questions = [
inquirer.Checkbox(
"interests",
message="What are you interested in?",
choices=["Computers", "Books", "Science", "Nature", "Fantasy", "History"],
default=["Computers", "Books"],
),
]
answers = inquirer.prompt(questions)
pprint(answers)
print(yaml.dump(answers))
产生:
[?] What are you interested in?:
X Computers
o Books
如何将“X”和“o”分别更改为“Y”和“N”?
PS:XOXO 的意思是“拥抱和亲吻”是很普遍的知识,因此在某些工作环境中可能并不合适。