Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我正在做一个项目,我正在创建一个名为geolocation_client.py的文件。我一直收到错误,pycharm一直告诉我安装隐藏_Python_Pycharm_Geocoding - Fatal编程技术网

Python 我正在做一个项目,我正在创建一个名为geolocation_client.py的文件。我一直收到错误,pycharm一直告诉我安装隐藏

Python 我正在做一个项目,我正在创建一个名为geolocation_client.py的文件。我一直收到错误,pycharm一直告诉我安装隐藏,python,pycharm,geocoding,Python,Pycharm,Geocoding,我正在做一个项目,我正在创建一个名为geolocation_client.py的文件。我不断收到错误,pycharm不断告诉我安装隐藏,但我无法。 下面是我收到的一个错误示例 print("the stash is at ", stash.__str__()) NameError: name 'stash' is not defined 您正在访问函数外部不存在的变量 尝试: (1) “main()”中的“stash”只是一个局部变量(不存在于“main”之外)。您

我正在做一个项目,我正在创建一个名为geolocation_client.py的文件。我不断收到错误,pycharm不断告诉我安装隐藏,但我无法。 下面是我收到的一个错误示例

   print("the stash is at ", stash.__str__())
NameError: name 'stash' is not defined


您正在访问函数外部不存在的变量

尝试:


(1) “main()”中的“stash”只是一个局部变量(不存在于“main”之外)。您可以将其声明为“全局”。(2) 必须先调用“main”来定义“stash”,然后才能在函数外部使用它。好的,非常感谢您的帮助并解释我的程序没有正确编译的原因。谢谢您的帮助。我现在知道我的代码哪里出错了投票表决我的答案
from geolocation import GeoLocation

def main():
    stash = GeoLocation(34.988889, -106.614444)
    ABQstudio = GeoLocation(34.989978, -106.614357)
    FBIbuilding = GeoLocation(35.131281, -106.61263)

print("the stash is at ", stash.__str__())
print("ABQ stuido is at ", ABQstudio.__str__())
print("FBI building is at ", FBIbuilding.__str__())

print("distance in miles between:")
stash_studio = stash.distance_from(ABQstudio)
stash_fbi = stash.distance_from(FBIbuilding)

print(" stash/studio = ", stash_studio)
print(" stash/fbi = ", stash_fbi)

if __name__ == "__main__":
main()
from geolocation import GeoLocation

def main():
    stash = GeoLocation(34.988889, -106.614444)
    ABQstudio = GeoLocation(34.989978, -106.614357)
    FBIbuilding = GeoLocation(35.131281, -106.61263)

    print("the stash is at ", stash.__str__())
    print("ABQ stuido is at ", ABQstudio.__str__())
    print("FBI building is at ", FBIbuilding.__str__())

    print("distance in miles between:")
    stash_studio = stash.distance_from(ABQstudio)
    stash_fbi = stash.distance_from(FBIbuilding)

    print(" stash/studio = ", stash_studio)
    print(" stash/fbi = ", stash_fbi)

if __name__ == "__main__":
    main()