小编Rei*_*ion的帖子

检查版本/是否安装了 PROJ4

我在使用地理空间库方面真的很新,我已经能够安装 GDAL 和 PostGIS。我只是想检查我是否真的能够包含 PostGIS 所需的 GEOS 和 PROJ4 包。

我应该输入哪些命令行来检查它们的版本或它们是否已安装?谢谢!

编辑(我只需要 proj4 检查):

PostGreSQL 版本: $ psql --version

PostGIS 版本:连接到您的数据库, =# SELECT PostGIS_full_version();

GDAL 版本: $ gdal-info --version

GEOS版本: $ geos-config --version

linux installation ubuntu geos proj

5
推荐指数
2
解决办法
6278
查看次数

Python:UnicodeEncodeError:'ascii'编解码器无法在位置 78 编码字符 u'\xf1':序号不在范围内(128)

我已经尝试了两种变体来解决这个问题,但会导致另一个错误。首先尝试encode和另一个尝试strip(#) 假设这是在此错误中捕获的问题:

"color":rcolor,"text_color":tcolor})
File "/usr/lib/python2.7/csv.py", line 152, in writerow
    return self.writer.writerow(self._dict_to_list(rowdict))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 78: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)

我的代码现在看起来像这样:

routes = db.routes.find()
    for route in routes:
        try:
            color = route["properties"]["color"]
            color = color.strip('#')
            print(color)

            tcolor = route["properties"]["tcolor"]
            tcolor = tcolor.strip('#')
            print(tcolor)
        except KeyError:
            color = "0000FF"
            tcolor = ""

        writer.writerow({"route_id":route["route_id"],
                   "agency_id":route["properties"]["agency_id"],...,
                   "route_color":color,"route_text_color":tcolor})
Run Code Online (Sandbox Code Playgroud)

我不太确定为什么它不断收到 unicode 错误...

python

5
推荐指数
1
解决办法
2068
查看次数

如何将值/参数从 HTML 传递到 Django 视图?

我认为我通常会在 ajax 中做到这一点。

但是,例如,如果我有一个按钮和一个将具有查询值的搜索输入框,我如何将搜索值(以及可能不是通过表单字段获得的多个值/参数)传递给按钮单击时的 Django 视图网址?

HTML

 <div>
    <input id="search" name="search" type="text" class="query-search" placeholder="Search...">
    <a class="btn btn-primary btn-lg btn-space col-sm-3" href="{% url 'routes_view' %}">View Routes</a>
 </div>
Run Code Online (Sandbox Code Playgroud)

观看次数

def view_detail(request): 
   ...
   <How to get values from HTML without using ajax? Or its the only way?>
Run Code Online (Sandbox Code Playgroud)

网址

url(r'^view/', views.view_detail, name='view_detail')
Run Code Online (Sandbox Code Playgroud)

python django

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

Python在","上拆分字符串,但想要的内容也在里面有","

给定一个字符串我想在每个分隔符","分开.但是,它的部分内容会找到导致输出错误的分隔符.

举个例子:

str = '"str1",,"str2","str,test,str3",3,5' 
print(str.split(","))

Output:
['"str1"', '', '"str2"', '"str', 'test', 'str3"', '3', '5']
Run Code Online (Sandbox Code Playgroud)

什么输出我需要的是:

['"str1"', '', '"str2"', '"str,test,str3"', '3', '5']
Run Code Online (Sandbox Code Playgroud)

我也尝试使用这个分隔符:

 print(str.split('",'))
Run Code Online (Sandbox Code Playgroud)

但是,字符串最初包含整数以及呈现输出:

['"str1', ',"str2', '"str,test,str3', '3,5']
Run Code Online (Sandbox Code Playgroud)

有没有解决方法?

python

2
推荐指数
1
解决办法
75
查看次数

标签 统计

python ×3

django ×1

geos ×1

installation ×1

linux ×1

proj ×1

ubuntu ×1