gdata.data.PhoneNumber:如何获取Phone号码的类型?

gdata.data.PhoneNumber: How do I get the type of Phone Number?

使用 class gdata.data.PhoneNumber,如何获取 phone 号码的类型 (Home/Business/Mobile/etc.)?

这是我引用的文档:https://gdata-python-client.googlecode.com/hg/pydocs/gdata.data.html#PhoneNumber

"rel" 属性应该就是您要查找的内容。 这是来自 https://github.com/google/gdata-python-client/blob/master/tests/gdata_tests/contacts/service_test.py:

的示例代码
# Create a new entry
new_entry = gdata.contacts.ContactEntry()
new_entry.title = atom.Title(text='Elizabeth Bennet')
new_entry.content = atom.Content(text='Test Notes')
new_entry.email.append(gdata.contacts.Email(
    rel='http://schemas.google.com/g/2005#work',
    primary='true',
    address='liz@gmail.com'))
new_entry.phone_number.append(gdata.contacts.PhoneNumber(
    rel='http://schemas.google.com/g/2005#work', text='(206)555-1212'))
new_entry.organization = gdata.contacts.Organization(
    org_name=gdata.contacts.OrgName(text='TestCo.'), 
    rel='http://schemas.google.com/g/2005#work')

它没有访问 "rel" 属性,但它在那里,我发誓 :)

获得 PhoneNumer 实例后,您可以使用 the built-in dir() function:

打印每个属性
print(dir(phone_number))

以下是"rel"的列表(https://github.com/google/gdata-python-client/blob/master/src/gdata/data.py)。我不知道是否所有都适用于 phone 数字,但它可能对检查类型有用:

FAX_REL = 'http://schemas.google.com/g/2005#fax'
HOME_REL = 'http://schemas.google.com/g/2005#home'
HOME_FAX_REL = 'http://schemas.google.com/g/2005#home_fax'
ISDN_REL = 'http://schemas.google.com/g/2005#isdn'
MAIN_REL = 'http://schemas.google.com/g/2005#main'
MOBILE_REL = 'http://schemas.google.com/g/2005#mobile'
OTHER_REL = 'http://schemas.google.com/g/2005#other'
OTHER_FAX_REL = 'http://schemas.google.com/g/2005#other_fax'
PAGER_REL = 'http://schemas.google.com/g/2005#pager'
RADIO_REL = 'http://schemas.google.com/g/2005#radio'
TELEX_REL = 'http://schemas.google.com/g/2005#telex'
TTL_TDD_REL = 'http://schemas.google.com/g/2005#tty_tdd'
WORK_REL = 'http://schemas.google.com/g/2005#work'
WORK_FAX_REL = 'http://schemas.google.com/g/2005#work_fax'
WORK_MOBILE_REL = 'http://schemas.google.com/g/2005#work_mobile'
WORK_PAGER_REL = 'http://schemas.google.com/g/2005#work_pager'
NETMEETING_REL = 'http://schemas.google.com/g/2005#netmeeting'

其他 "rel" 可以(或者应该?)与对象的 "label" 属性相结合。