Google App Engine:仅从db.UserProperty中提取用户名

时间:2011-06-10 02:16:20

标签: google-app-engine

我想知道从db.UserProperty中提取用户名(@符号前面的部分)的最佳方法是什么。也许有一种我不知道的内置方法?昵称方法返回完整的用户名。

2 个答案:

答案 0 :(得分:1)

来自Google appengine代码:

  

昵称是一个人类可读的字符串,可以唯一标识Google     用户,类似于用户名。它将是某些用户的电子邮件地址,但是     不是全部。

因此可能是用户名或电子邮件,具体取决于帐户。

答案 1 :(得分:0)

电子邮件()

Returns the email address of the user. If you use OpenID, you should not rely on this email address to be correct. Applications should use nickname for displayable names.

没有内置方法可以做到这一点。但你可以做这样的事吗

from google.appengine.api import users
user =user=users.get_current_user()

email = user.email()
username = str(email).split('@')[0]