使用终端命令进入 python 代码
using terminal command into python code
我有一个名为 myosm.osm 的文件。如果我 运行 命令
$ ogrinfo myosm.osm
然后我得到以下输出:
Had to open data source read-only.
INFO: Open of `myosm.osm'
using driver `OSM' successful.
1: points (Point)
2: lines (Line String)
3: multilinestrings (Multi Line String)
4: multipolygons (Multi Polygon)
5: other_relations (Geometry Collection)
我想在我的 python 代码中实现这个命令,并希望在变量中获取输出以供进一步使用。
使用plumbum:
from plumbum.cmd import ogrinfo
output = ogrinfo('myosm.osm')
(安装:pip install plumbum
)
我有一个名为 myosm.osm 的文件。如果我 运行 命令
$ ogrinfo myosm.osm
然后我得到以下输出:
Had to open data source read-only.
INFO: Open of `myosm.osm'
using driver `OSM' successful.
1: points (Point)
2: lines (Line String)
3: multilinestrings (Multi Line String)
4: multipolygons (Multi Polygon)
5: other_relations (Geometry Collection)
我想在我的 python 代码中实现这个命令,并希望在变量中获取输出以供进一步使用。
使用plumbum:
from plumbum.cmd import ogrinfo
output = ogrinfo('myosm.osm')
(安装:pip install plumbum
)