2013-01-25 48 views
2

可能有點小問。對於那個很抱歉。嘗試這種https://github.com/mutaku/pygeocoding圖書館,做了像這樣使用pygeocoding獲取地址的經度和緯度

print LookUp(latlng="39.9518819802915,-75.1476150197085") 

查找,但它給了我

'初始化()應該返回無'

我做了什麼錯?

在此先感謝。與

self.result=result #assign the result to a LookUp instance 

return result

,然後運行:

+0

你有沒有一個'從做打印之前的pygeocoding import *'? – asheeshr

+0

是的,我確實導入它。否則會返回全局名稱'pygeocoding'未定義 – tipsywacky

+0

這是在黑暗中拍攝的。嘗試從https://github.com/mutaku/pygeocoding/blob/master/pygeocoding/api.py刪除第87行,然後使用它。 – asheeshr

回答

3

我認爲有在代碼中的錯誤,更換線路

In [1]: from pygeocoding import * 

In [2]: r=LookUp(latlng="39.9518819802915,-75.1476150197085") 

In [3]: r.result 
Out[3]:  

{u'results': [{u'address_components': [{u'long_name': u'400', 
     u'short_name': u'400', 
     u'types': [u'street_number']}, 
    {u'long_name': u'Arch Street', 
     u'short_name': u'Arch St', 
     u'types': [u'route']}, 
    {u'long_name': u'Center City', 
     u'short_name': u'Center City', 
     u'types': [u'neighborhood', u'politi ....................} 
+0

非常感謝。它的作用就像一種魅力。 – tipsywacky

+0

@tipsywacky很高興幫助,如果可能的話,然後指出這個錯誤給作者。 –

+0

@AshwiniChaudhary感謝您對此提供幫助。我是這個項目的作者,在相當一段時間裏我沒有觸及過這些代碼,並忘記了一些尚未解決的問題。 工作更新與[提交這裏(https://github.com/mutaku/pygeocoding/commit/e4f635d06b5b356a0aae9d7d04b1e98bd560973f) 感謝,並請隨意添加任何問題/錯誤的項目的問題部分應主動你遇到任何或希望請求任何功能/改進! – Matthew