方法一:在系统环境中显示
$ pydoc modules
方法二:在 Python3 环境下显示
2.1 进入 Python3 模式
# python3
2.2 显示所有已安装的模块
>>> help('modules')
2.3 退出 Python3 模式
>>> quit()
$ pydoc modules
# python3
>>> help('modules')
>>> quit()
在重建 Django 数据表之前要先安装 Django 服务
(django_env) [root@python mysite]# python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
1. 给此脚本添加执行权限
2. 执行此脚本
此脚本不能命名为 json.py
#!/usr/bin/python3
import json
hostlist = {}
hostlist["web"] = ["192.168.100.101", "192.168.100.102"]
hostlist["db"] = {
"hosts" :["192.168.100.121", "192.168.100.122"],
"vars" :{"ansible_ssh_user":"root", "ansible_ssh_pass":"1"}
}
hostlist["192.168.100.110"] = {
"ansible_ssh_user":"root", "ansible_ssh_pass":"pwd"
}
print(json.dumps(hostlist))