ここにPythonが新しくあります。私はこのようになりますYAMLファイルに保存されているユーザーのリストを持っている:PythonはYAMLファイルを解析して値を出力します
users:
test:
dn: dc=test
cn: test
objectClass:
- inetOrgPerson
- person
- ldapPublicKey
- posixAccount
employeeType: inactive
test2:
dn: dc=test
cn: test2
objectClass:
- inetOrgPerson
- person
- ldapPublicKey
- posixAccount
employeeType: inactive
私はwhosは従業員のタイプが非アクティブであるすべてのユーザーのために、このファイルを照会することができるようにしたい、と私は、ユーザー名を印刷したいです、上記の例ではtest2となります。私は次のスクリプトが書かれているが、それはすべてのユーザーを返す、誰かが私が行方不明に私を指すのに役立つことができますか?
#!/usr/bin/env python
import os
import yaml
import ldap
with open('ldap_users.yaml', 'r') as file:
doc = yaml.load(file)
for employeeType, inactive in doc['users'].iteritems():
print employeeType, inactive