python - 如何将变量放入 geolocator.reverse() 函数?
问题描述
我有lat1
并lng1
设置。当我尝试时:
location = geolocator.reverse('lat1', 'lng1')
它给了我错误:
类型错误
Traceback (most recent call last)
<ipython-input-65-bef81ce5884b> in <module>
----> 1 location = geolocator.reverse('lat1', 'lng1')
TypeError: reverse() takes 2 positional arguments but 3 were given
当我在没有'的情况下尝试它时,它给了我一个语法错误。
解决方案
您可以使用以下代码:
location = geolocator.reverse("{}, {}".format(lat1, lng1))
上面的代码将变量格式化为.reverse()
方法的字符串。
推荐阅读
- svg - svg 2.0 需要哪些 css 函数
- blazor-webassembly - 单击后退按钮后未调用 Javascript
- rust - 类型别名 `Point2` 在 Rust 中是私有的
- angular - 用于角业力测试的自定义 webpack 配置不能解析组件但适用于指令
- c# - 使用反射从类对象中获取属性,其中属性应该是公共的,并且具有 get 或 get 和 set 两者
- apache-kafka - 不能将单个消费者组的超过 3 个 kafka 消费者放入单个进程中
- amazon-web-services - 我的用户数据脚本没有从 ssm 获取参数
- c - 如何为 printf 设置条件以仅从文件中打印特定项目的数据
- c# - 当我尝试创建迁移时缺少 .dll
- c++ - 类初始化没有匹配的构造函数