Python PyGithub 对 get/remove 组织成员的使用

Python PyGithub usage to get/remove a member in an organization

我是 Python 和 Github API 的新手,目前正在尝试使用 Pygithub 访问 Github 企业 API。目标是查找特定成员是否在组织中。如果是这样,请将其从组织中删除。 我的当前代码如下:

access_token = "my_ghe_org_token"
g = Github(base_url="https://{my_ghe_hostname}/api/v3", login_or_token=access_token)
org = g.get_organization('my_org_name')
mem_exist = org.has_in_members('myu')
if mem_exist:
    org.remove_from_members('myu')

它给出以下错误:

    Traceback (most recent call last):
  File "disable_ghe.py", line 21, in <module>
    disable_ghe()
  File "disable_ghe.py", line 9, in disable_ghe
    mem_exist = org.has_in_members('myu')
  File "/Users/myu/Desktop/github/venv/lib/python3.6/site-packages/github/Organization.py", line 769, in has_in_members
    assert isinstance(member, github.NamedUser.NamedUser), member

有人知道我的错误在哪里吗?或者如果我错误地使用了函数,请解释一下?

我正在尝试拨打这个电话:http://pygithub.readthedocs.io/en/stable/github_objects/Organization.html#github.Organization.Organization.has_in_members

需要先获取用户,然后在has_in_membersremove_from_members[=15=里面传递用户对象].

user = g.get_user('myu')
mem_exist = org.has_in_members(user)

if mem_exist:
    org.remove_from_members(user)