小编cod*_*ojo的帖子

在 Swift 中将城市名称转换为坐标

我在 SO 上看到的问题很少,但它们在 Swift 2 中都是旧的。我从 Apple 网站获得了这个函数,用于将城市名称转换为纬度和经度,但我不确定该函数将返回什么(因为 return 语句之后没有任何内容) 我应该通过什么。有人会解释一下吗,或者请告诉我如何使用它。

func getCoordinate( addressString : String, 
        completionHandler: @escaping(CLLocationCoordinate2D, NSError?) -> Void ) {
    let geocoder = CLGeocoder()
    geocoder.geocodeAddressString(addressString) { (placemarks, error) in
        if error == nil {
            if let placemark = placemarks?[0] {
                let location = placemark.location!

                completionHandler(location.coordinate, nil)
                return
            }
        }

        completionHandler(kCLLocationCoordinate2DInvalid, error as NSError?)
    }
}
Run Code Online (Sandbox Code Playgroud)

xcode google-maps ios swift

4
推荐指数
1
解决办法
2091
查看次数

如何使Flask默认使用Python 3

我正在尝试在Ubuntu 16服务器(Apache2)上部署Flask项目.在这个项目中,我使用的是Python3库.所以我想将Flask设置为在服务器上使用Python 3.但我真的很难受.这是我在做的事情:

sudo apt-get install apache2
sudo apt-get update
sudo apt-get install libapache2-mod-wsgi-py3 # I think that is how you install wsgi for python3
sudo apt-get install python-flask
sudo apt-get upgrade
Run Code Online (Sandbox Code Playgroud)

我的项目conf: /etc/apache2/sites-available/project.conf

<VirtualHost *:80>
    ServerName 52.25.54.241 #my IP
    ServerAdmin admin@mywebsite.com 
    WSGIScriptAlias / /var/www/FlaskApps/FlaskApps.wsgi
    <Directory /var/www/FlaskApps/project/>
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/FlaskApps/project/static/>
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

最后: /var/www/FlaskApps/FlaskApps.wsgi

#! /usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApps/project/")

# …
Run Code Online (Sandbox Code Playgroud)

python mod-wsgi flask python-3.x

3
推荐指数
1
解决办法
2715
查看次数

标签 统计

flask ×1

google-maps ×1

ios ×1

mod-wsgi ×1

python ×1

python-3.x ×1

swift ×1

xcode ×1