0
我在想什么是从db.UserProperty中提取用户名(@符号前的部分)的最佳方法。也许有一种我不知道的内置方法?昵称方法正在返回完整的用户名。Google App Engine:从db.UserProperty中提取用户名
我在想什么是从db.UserProperty中提取用户名(@符号前的部分)的最佳方法。也许有一种我不知道的内置方法?昵称方法正在返回完整的用户名。Google App Engine:从db.UserProperty中提取用户名
电子邮件()
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]
从谷歌应用服务引擎的代码:
昵称是人类可读的字符串它唯一地标识一个谷歌 用户,类似于用户名。这将是一些用户的电子邮件地址,但不是全部。
所以它可能是用户名或电子邮件取决于帐户。
记住,电子邮件地址的用户部分在技术上可以包含一个“@”符号(虽然我从来没有见过一个在野外)。您应该使用rsplit来查找_last_ @符号左侧的所有内容。 – 2011-06-11 07:56:47