当前位置: 首页>>代码示例>>Python>>正文


Python simplejson.has_key函数代码示例

本文整理汇总了Python中simplejson.has_key函数的典型用法代码示例。如果您正苦于以下问题:Python has_key函数的具体用法?Python has_key怎么用?Python has_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了has_key函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _set_url

 def _set_url(self, json):
     self.url = None
     if json.has_key('trackViewUrl'):
         self.url = json['trackViewUrl']
     elif json.has_key('collectionViewUrl'):
         self.url = json['collectionViewUrl']
     elif json.has_key('artistViewUrl'):
         self.url = json['artistViewUrl']
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:8,代码来源:__init__.py

示例2: _set_artwork

 def _set_artwork(self, json):
     self.artwork = dict()
     if json.has_key('artworkUrl30'):
         self.artwork['30'] = json['artworkUrl30']
     if json.has_key('artworkUrl60'):
         self.artwork['60'] = json['artworkUrl60']
     if json.has_key('artworkUrl100'):
         self.artwork['100'] = json['artworkUrl100']
     if json.has_key('artworkUrl512'):
         self.artwork['512'] = json['artworkUrl512']
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:10,代码来源:__init__.py

示例3: _set

    def _set(self, json):
        super(Track, self)._set(json)
        # Track information
        self.name = json['trackName']
        self.url = json.get('trackViewUrl', None)
        self.preview_url = json.get('previewUrl', None)
        self.price = None
        if json.has_key('trackPrice') and json['trackPrice'] is not None:
            self.price = round(json['trackPrice'], 4)
        self.number = json.get('trackNumber', None)
        self.duration = None
        if json.has_key('trackTimeMillis') and json['trackTimeMillis'] is not None:
            self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)

        self._set_artist(json)
        self._set_album(json)
开发者ID:paul-obrien,项目名称:python-itunes,代码行数:16,代码来源:__init__.py

示例4: get

    def get(self):
        self._json_results = self._request(cacheable=is_caching_enabled())
        if self._json_results.has_key('errorMessage'):
            raise ServiceException(type='Error', message=self._json_results['errorMessage'])
        self._num_results = self._json_results['resultCount']
        l = []
        for json in self._json_results['results']:
            type = None
            if json.has_key('wrapperType'):
                type = json['wrapperType']
            elif json.has_key('kind'):
                type = json['kind']

            if type == 'artist':
                id = json['artistId']
                item = Artist(id)
            elif type == 'collection':
                id = json['collectionId']
                item = Album(id)
            elif type == 'track':
                id = json['trackId']
                item = Track(id)
            elif type == 'audiobook':
                id = json['collectionId']
                item = Audiobook(id)
            elif type == 'ebook':
                id = json['trackId']
                item = Ebook(id)
            elif type == 'software':
                id = json['trackId']
                item = Software(id)
            else:
                if json.has_key('collectionId'):
                    id = json['collectionId']
                elif json.has_key('artistId'):
                    id = json['artistId']
                item = Item(id)
            item._set(json)
            l.append(item)
        return l
开发者ID:c0ns0le,项目名称:Pythonista,代码行数:40,代码来源:__init__.py

示例5: _set

 def _set(self, json):
     self.json = json
     #print json
     if json.has_key('kind'):
         self.type = json['kind']
     else:
         self.type = json['wrapperType']
     # Item information
     self._set_genre(json)
     self._set_release(json)
     self._set_country(json)
     self._set_artwork(json)
     self._set_url(json)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:13,代码来源:__init__.py

示例6: __init__

    def __init__(self, id=None, json=None, username=None, token=None):
        self.id = id
        self._json = json
        self._username = username
        self._token = token

        # Map given repo id to gist id if none exists
        if self._json:
            self.id = json["repo"] if json.has_key("repo") else json["id"]

        self.url = url = GIST_BASE % self.id
        self.embed_url = url + ".js"
        self.epic_embed_url = url + ".pibb"
        self.json_url = url + ".json"
        self.post_url = GIST_BASE % "gists/%s" % self.id
开发者ID:fukata,项目名称:gist-cli,代码行数:15,代码来源:core.py

示例7: _simplify_json

 def _simplify_json(self, json):
     result = {}
     # First, resolve references
     for element in json.values():
         for k,v in element.items():
             if isinstance(v, unicode) and v.startswith("http://") and json.has_key(v):
                 element[k] = json[v]
     for k, v in json.items():
         if v.has_key("_typeGroup"):
             group = v["_typeGroup"]
             if not result.has_key(group):
                 result[group]=[]
             del v["_typeGroup"]
             v["__reference"] = k
             result[group].append(v)
     return result
开发者ID:maple7sha,项目名称:studentorigin_opencalais,代码行数:16,代码来源:calais.py

示例8: _set_album

 def _set_album(self, json):
     if json.has_key('collectionId'):
         id = json['collectionId']
         self.album = Album(id)
         self.album._set(json)
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:5,代码来源:__init__.py

示例9: _set_release

 def _set_release(self, json):
     self.release_date = None
     if json.has_key('releaseDate') and json['releaseDate']:
         self.release_date = json['releaseDate'].split('T')[0]
开发者ID:flyhawk007,项目名称:python-itunes,代码行数:4,代码来源:__init__.py

示例10: _set_current_version_release_date

 def _set_current_version_release_date(self, json):
     self.current_version_release_date = None
     if json.has_key('currentVersionReleaseDate') and json['currentVersionReleaseDate']:
         self.current_version_release_date = datetime.datetime.strptime( json['currentVersionReleaseDate'], r'%Y-%m-%dT%H:%M:%SZ' )
开发者ID:ocelma,项目名称:python-itunes,代码行数:4,代码来源:__init__.py


注:本文中的simplejson.has_key函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。