2015-09-26 12 views
0

我需要知道變量的類型,但是這是我暫時無法確定如何進行比較tweepy - >如何檢測的<class「tweepy.models.User」的類型> -

像這:

if temp== <class 'tweepy.models.Status'>: 


favorited --> <type 'bool'> 
contributors --> <type 'NoneType'> 
truncated --> <type 'bool'> 
text --> <type 'unicode'> 
source_url --> <type 'str'> 
possibly_sensitive --> <type 'bool'> 
is_quote_status --> <type 'bool'> 
in_reply_to_status_id --> <type 'NoneType'> 
user --> <class 'tweepy.models.User'> 
geo --> <type 'NoneType'> 
id --> <type 'long'> 
favorite_count --> <type 'int'> 
lang --> <type 'str'> 
retweeted_status --> <class 'tweepy.models.Status'> 
entities --> <type 'dict'> 
created_at --> <type 'datetime.datetime'> 
author --> <class 'tweepy.models.User'> 
retweeted --> <type 'bool'> 
coordinates --> <type 'NoneType'> 
in_reply_to_user_id_str --> <type 'NoneType'> 
source --> <type 'str'> 
in_reply_to_status_id_str --> <type 'NoneType'> 
in_reply_to_screen_name --> <type 'NoneType'> 
in_reply_to_user_id --> <type 'NoneType'> 
extended_entities --> <type 'dict'> 
place --> <type 'NoneType'> 
retweet_count --> <type 'int'> 
id_str --> <type 'str'> 

保險很簡單,它會幫助我,如果可能的話幫助你。

謝謝。

回答

1

如果我理解正確的,你要的是if type(temp) is tweepy.models.Status:,而不是if temp== <class 'tweepy.models.Status'>:

1

很好,蟒蛇類型可比的單身人士,所以

if type(A) == type(B): 
    ... 

將很好地工作。

而且

if type(object_of_yours) == tweepy.models.Status: 
    ... 

會工作。

+0

完美,所以我解析謝謝 –

相關問題