问题描述
我正在使用PyGithub库邀请新成员加入该组织.我面临的问题是下一个:在这种情况下,当我只知道用户的主要电子邮件地址时,如何检索他的用户名以继续进行邀请?我知道可以通过UI进行操作,但是无法通过API找到相应的调用.请帮忙!
I'm using the PyGithub library to invite new member to the organization. The issue I faced is the next:In the scenario, when I know only users primary email, how can I retrieve his username to proceed invite accordingly?I know it is possible through UI, but can't find the corresponding call through API.Please, assist!
推荐答案
PyGithub API
请参考 search_users
- 查询–字符串
- 排序-字符串(关注者",存储库",已加入")
- order –字符串("asc","desc")
- 限定词–关键字dict查询限定词
- query – string
- sort – string (‘followers’, ‘repositories’, ‘joined’)
- order – string (‘asc’, ‘desc’)
- qualifiers – keyword dict query qualifiers
例如
g = github.Github("USERNAME", "PASSWORD")
users = g.search_users("franky in:email")
for user in users:
print(user.login) # print the selected users' username.
GitHub API
根据GitHub API 搜索用户 ,则只能使用关键字in
指定仅通过公共电子邮件进行搜索.
GitHub API
According to GitHub API Search users, you can specify only searching by public email using keyword in
.
例如
https://api.github.com/search/users ?q = franky + in:电子邮件
然后,您只会在其中收到带有坦率"字样的用户.
Then, you'll only get users with "franky" in there emails.
这篇关于通过主要电子邮件获取github用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!