高德5Python 地图坐标的转换 .docxPython 地图坐标的转换

高德5Python 地图坐标的转换 .docxPython 地图坐标的转换

Python 地图坐标的转换

最近做项目正好需要坐标的转换,

找了很多资料,参考:

1、http://blog.csdn.net/ma969070578/article/details/41013547

2、http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=10923

在线的测试工具 https://tool.lu/coordinate  

python 编写的经纬度坐标转换类

# -*- coding: utf-8 -*-

# /**

#  * 各地图API坐标系统比较与转换;

#  * WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,

#  * 谷歌地图采用的是WGS84地理坐标系(中国范围除外);

#  * GCJ02坐标系:即火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系;

#  * 3BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系;

#  */

import math

from decimal import *

class transfer:

    def __init__(self,key=None):

        self.a=6378245.0

        self.ee=Decimal(0.00669342162296594323)

    def transformLng(self,x,y):

        ret=Decimal()

        ret = 300.0+x+2.0*y+0.1*x*x+0.1*x*y+0.1*math.sqrt(math.fabs(x))

        ret += (20.0 * math.sin(6.0 * x * math.pi) + 20.0 * math.sin(2.0 * x * math.pi)) * 2.0 / 3.0

        ret += (20.0 * math.sin(x * math.pi) + 40.0 * math.sin(x / 3.0 * math.pi)) * 2.0 / 3.0

        ret += (150.0 * math.sin(x / 12.0 * math.pi) + 300.0 * math.sin(x / 30.0* math.pi)) * 2.0 / 3.0

        return ret

    def transformLat(self,x,y):

        ret = Decimal()

        ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y+ 0.2 * math.sqrt(math.fabs(x))

        ret += (20.0 * math.sin(6.0 * x * math.pi) + 20.0 * math.sin(2.0 * x * math.pi)) * 2.0 / 3.0

        ret += (20.0 * math.sin(y * math.pi) + 40.0 * math.sin(y / 3.0 * math.pi)) * 2.0 / 3.0

        ret += (160.0 * math.sin(y / 12.0 * math.pi) + 320 * math.sin(y * math.pi / 30.0)) * 2.0 / 3.0

        return ret

    def transfrom(self,lng,lat):

        dLat = self.transformLat(lng - 105.0, lat - 35.0)

        dLng = self.transformLng(lng - 105.0, lat - 35.0)

        radLat = lat / 180.0 * math.pi

        magic = math.sin(radLat)

        magic = 1 - self.ee * Decimal(magic) * Decimal(magic)

        sqrtMagic = math.sqrt(magic)

        dLat = Decimal((dLat * 180.0)) / ((Decimal(self.a) * (1 - self.ee)) / (Decimal(magic) * Decimal(sqrtMagic)) * Decimal(math.pi))

        dLng = (dLng * 180.0) / (self.a / sqrtMagic * math.cos(radLat) * math.pi)

        mgLat = lat + float(dLat)

        mgLng = lng + dLng

        return mgLng,mgLat

    #gps坐标转换为gcj02坐标系

    def wg84_to_gcj02(self,wg84_lng,wg84_lat):

        dLat=self.transformLat(wg84_lng-105.0,wg84_lat-35.0)

        dLng=self.transformLng(wg84_lng-105.0,wg84_lat-35.0)

        radLat = wg84_lat / 180.0 * math.pi

        magic = math.sin(radLat)

        magic = 1 - self.ee * Decimal(magic) * Decimal(magic)

        sqrtMagic = math.sqrt(magic)

        dLat = Decimal((dLat * 180.0)) / ((Decimal(self.a) * (1 - self.ee)) / (Decimal(magic) * Decimal(sqrtMagic)) * Decimal(math.pi))

        dLng = (dLng * 180.0) / (self.a / sqrtMagic * math.cos(radLat) * math.pi)

        gcj02Lat = wg84_lat + float(dLat)

        gcj02Lng = wg84_lng + dLng

        return gcj02Lng,gcj02Lat

    #gcj02坐标转百度坐标

    def gcj02_to_bd09(self,gcj02_lng,gcj02_lat):

        x = gcj02_lng

        y = gcj02_lat

        z = math.sqrt(x * x + y * y) + 0.00002 * math.sin(y * math.pi)

        theta = math.atan2(y, x) + 0.000003 * math.cos(x * math.pi)

        bd09_Lng = z * math.cos(theta) + 0.0065

        bd09_Lat = z * math.sin(theta) + 0.006

        return bd09_Lng,bd09_Lat

    #wg84坐标转百度坐标

    def wg84_to_bd09(self,wg84_lng,wg84_lat):

        gcj02lng,gcj02lat=self.wg84_to_gcj02(wg84_lng,wg84_lat)

        return self.gcj02_to_bd09(gcj02lng,gcj02lat)

    #百度坐标转GCJ02坐标

    def bd09_to_gcj02(self,bd09_lng,bd09_lat):

        x = bd09_lng - 0.0065

        y = bd09_lat - 0.006

        z = math.sqrt(x * x + y * y) - 0.00002 * math.sin(y * math.pi)

        theta = math.atan2(y, x) - 0.000003 * math.cos(x * math.pi)

        gcj02_lng = z * math.cos(theta)

        gcj02_lat = z * math.sin(theta)

        return gcj02_lng,gcj02_lat

    #GCJ坐标转WG84坐标

    def gcj02_to_wg84(self,gcj02_lng,gcj02_lat):

        mlng,mlat=self.transfrom(gcj02_lng,gcj02_lat)

        wg84_Lng=gcj02_lng*2-mlng

        wg84_Lat=gcj02_lat*2-mlat

        return wg84_Lng,wg84_Lat

    #将百度坐标转WG84坐标

    def bd09_to_wg84(self,bd09_lng,bd09_lat):

        gcj02_lng, gcj02_lat=self.bd09_to_gcj02(bd09_lng,bd09_lat)

        return self.gcj02_to_wg84(gcj02_lng,gcj02_lat)

tr=transfer()

#测试

print(tr.bd09_to_gcj02(113.30764968,23.1200491))  #转换正确

print(tr.bd09_to_wg84(113.30764968,23.1200491))  #转换正确

print(tr.wg84_to_bd09(113.30764968,23.1200491))  #转换正确

由python实现的各类坐标系转换程序,验证可行

在线的测试工具 https://tool.lu/coordinate  

 

 

地图坐标转换(火星、谷歌、百度、腾讯、高德等坐标)

最近在项目中集成百度地图API和高德API的时候,发现定位总是有偏移,考虑到我们项目中的硬件是自己制作的,最后跟踪了半天预估是未做坐标转换造成的。由此引出本文的话题,为什么我的坐标,在地图上显示会有偏移?各种坐标体系之间如何转换?到底有哪些坐标体系?什么是火星坐标?

1. 概念解释

首先搞清楚什么是火星坐标?到底有哪些坐标体系?由来是怎样的?

1.1 名词解释

坐标系统:用于定位的系统,就跟二维笛卡尔坐标系统一样,一个点使用(x,y),就能确定该点在笛卡尔坐标系统中的唯一位置。这里讲的坐标系统,相对于笛卡尔坐标系统,要复杂许多,但作用却都是一样,主要用于定位,也就是精确地定位地表上的一点。
地理坐标系统:WGS84就是一种地理坐标系统。地理坐标坐标是对地球进行简单几何建模,比如将地球看成一个球体或者类球体,然后再将地表上点投影到该球面上形成的坐标就是地理坐标系统。WGS84就是定义了如何将地球抽象成球体或者类球体的规则。或者简单地来说,WGS84就是一堆参数,用于建立球体或者类球体,来近似地球。
投影坐标系统:由于地球是一个球状,所以一般将其某个区域投影在平面上,形成的坐标系称为投影坐标系。

1.2 简称解释

WGS84 :地理坐标系统,Google Earth和中国外的Google Map使用,另外,目前基本上所有定位空间位置的设备都使用这种坐标系统,例如手机的GPS系统。
GCJ-02:投影坐标系统,也就是我们平常所说的火星坐标系,Google Map中国、高德和腾讯好像使用,这个是中国自己在WGS84基础上加密而成,目的显而易见。
BD09:投影坐标系统,百度地图使用,在GCJ-02基础上二次加密而成。

国内各地图API坐标系统比较

API

坐标系

百度地图API

百度坐标

腾讯搜搜地图API

火星坐标

搜狐搜狗地图API

搜狗坐标

阿里云地图API

火星坐标

图吧MapBar地图API

图吧坐标

高德MapABC地图API

火星坐标

灵图51ditu地图API

火星坐标

2. 转换方法

在我们清楚这些名词意义、API所对应的坐标系之后,接下来就是找寻坐标系相互转换的方法了。
1.可以通过嗲用直接的算法来转换
2.可以通过Web API来转换
3.可以通过第三方SDK API来转换

2.1 通过算法转换

GPS.java

package com.itbird.myapplication;

 

/**

 * 坐标对象,由经纬度构成

 * Created by xfkang on 2018/3/28.

 */

 

public class GPS {

    private double lat;

    private double lon;

 

    public GPS(double lat, double lon) {

        this.lat = lat;

        this.lon = lon;

    }

 

    public double getLat() {

        return lat;

    }

 

    public void setLat(double lat) {

        this.lat = lat;

    }

 

    public double getLon() {

        return lon;

    }

 

    public void setLon(double lon) {

        this.lon = lon;

    }

 

    public String toString() {

        return "lat:" + lat + "," + "lon:" + lon;

    }

}

 

GPSConverterUtils.java

package com.itbird.myapplication;

 

/**

 * 坐标转换工具类

 * WGS84: Google Earth采用,Google Map中国范围外使用

 * GCJ02: 火星坐标系,中国国家测绘局制定的坐标系统,由WGS84机密后的坐标。Google Map中国和搜搜地图使用,高德

 * BD09:百度坐标,GCJ02机密后的坐标系

 * 搜狗坐标系,图吧坐标等,估计也是在GCJ02基础上加密而成的

 * Created by xfkang on 2018/3/28.

 */

 

public class GPSConverterUtils {

    public static final String BAIDU_LBS_TYPE = "bd09ll";

    public static double pi = 3.1415926535897932384626;

    public static double a = 6378245.0;

    public static double ee = 0.00669342162296594323;

 

    /**

     * 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System

     * @param lat

     * @param lon

     */

    public static GPS gps84_To_Gcj02(double lat, double lon) {

        if (outOfChina(lat, lon)) {

            return null;

        }

        double dLat = transformLat(lon - 105.0, lat - 35.0);

        double dLon = transformLon(lon - 105.0, lat - 35.0);

        double radLat = lat / 180.0 * pi;

        double magic = Math.sin(radLat);

        magic = 1 - ee * magic * magic;

        double sqrtMagic = Math.sqrt(magic);

        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);

        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);

        double mgLat = lat + dLat;

        double mgLon = lon + dLon;

        return new GPS(mgLat, mgLon);

    }

 

    /**

     * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return

     */

    public static GPS gcj_To_Gps84(double lat, double lon) {

        GPS gps = transform(lat, lon);

        double lontitude = lon * 2 - gps.getLon();

        double latitude = lat * 2 - gps.getLat();

        return new GPS(latitude, lontitude);

    }

 

    /**

     * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标

     *

     * @param gg_lat

     * @param gg_lon

     */

    public static GPS gcj02_To_Bd09(double gg_lat, double gg_lon) {

        double x = gg_lon, y = gg_lat;

        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);

        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);

        double bd_lon = z * Math.cos(theta) + 0.0065;

        double bd_lat = z * Math.sin(theta) + 0.006;

        return new GPS(bd_lat, bd_lon);

    }

 

    /**

     * * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param

     * bd_lat * @param bd_lon * @return

     */

    public static GPS bd09_To_Gcj02(double bd_lat, double bd_lon) {

        double x = bd_lon - 0.0065, y = bd_lat - 0.006;

        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);

        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);

        double gg_lon = z * Math.cos(theta);

        double gg_lat = z * Math.sin(theta);

        return new GPS(gg_lat, gg_lon);

    }

 

    /**

     * (BD-09)-->84

     * @param bd_lat

     * @param bd_lon

     * @return

     */

    public static GPS bd09_To_Gps84(double bd_lat, double bd_lon) {

 

        GPS gcj02 = bd09_To_Gcj02(bd_lat, bd_lon);

        GPS map84 = gcj_To_Gps84(gcj02.getLat(),

                gcj02.getLon());

        return map84;

 

    }

 

    /**

     * is or not outOfChina

     * @param lat

     * @param lon

     * @return

     */

    public static boolean outOfChina(double lat, double lon) {

        if (lon < 72.004 || lon > 137.8347)

            return true;

        if (lat < 0.8293 || lat > 55.8271)

            return true;

        return false;

    }

 

    public static GPS transform(double lat, double lon) {

        if (outOfChina(lat, lon)) {

            return new GPS(lat, lon);

        }

        double dLat = transformLat(lon - 105.0, lat - 35.0);

        double dLon = transformLon(lon - 105.0, lat - 35.0);

        double radLat = lat / 180.0 * pi;

        double magic = Math.sin(radLat);

        magic = 1 - ee * magic * magic;

        double sqrtMagic = Math.sqrt(magic);

        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);

        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);

        double mgLat = lat + dLat;

        double mgLon = lon + dLon;

        return new GPS(mgLat, mgLon);

    }

 

    public static double transformLat(double x, double y) {

        double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y

                + 0.2 * Math.sqrt(Math.abs(x));

        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;

        ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;

        ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;

        return ret;

    }

 

 

    public static double transformLon(double x, double y) {

        double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1

                * Math.sqrt(Math.abs(x));

        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;

        ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;

        ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0

                * pi)) * 2.0 / 3.0;

        return ret;

    }

}

2.2通过Web API转换

高德坐标转换Web API
在线api文档:http://lbs.amap.com/api/webservice/guide/api/convert/
适用场景:
为了使用高德服务,只支持将非高德坐标转换为高德坐标
使用说明:
第一步,申请”Web服务API”密钥(Key);
第二步,拼接HTTP请求URL,第一步申请的Key需作为必填参数一同发送;
第三步,接收HTTP请求返回的数据(JSON或XML格式),解析数据。
如无特殊声明,接口的输入参数和输出数据编码全部统一为UTF-8。
使用样例:
http://restapi.amap.com/v3/assistant/coordinate/convert?locations=116.481499,39.990475&coordsys=gps&output=xml&key=<用户的key>

 

 

高德坐标转换API使用样例.png

 

百度坐标转换Web API
在线api文档:http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
适用场景:
支持多种坐标互相转换

 

 

百度坐标转换WebAPI.png

 

GPS坐标转换Web API
在线api文档:http://www.gpsspg.com/api/convert/latlng/
适用场景:
支持多种坐标互相转换

 

 

GPS坐标转换WebAPI.png

 

2.3通过SDK API转换

高德 sdk api 转换
在线api文档:http://lbs.amap.com/api/android-sdk/guide/computing-equipment/coordinate-transformation/

 

 

高德 sdk api 转换.png

 

百度 sdk api 转换
在线api文档:http://lbsyun.baidu.com/index.php?title=androidsdk/guide/tool/coordinate

 

 

百度 sdk api 转换.png

 

总结:

至此,几种地图坐标系由来介绍以及相互转换的几种方法已经介绍完毕,视情况选取自己项目适合的方法,完成坐标转换即可。

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Python 地图坐标的转换

最近做项目正好需要坐标的转换,

找了很多资料,参考:

1、http://blog.csdn.net/ma969070578/article/details/41013547

2、http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=10923

 

 

 /// <summary>

        /// 从经纬坐标串生成 投影坐标下的线

        /// </summary>

        /// <param name="gcsStr"></param>

        /// <returns></returns>

        public static IPolyline GetLinePCSFromGCSStr(string gcsStr)

        {

            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();

            IProjectedCoordinateSystem pcsSys = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCS4Type.esriSRProjCS_Xian1980_3_Degree_GK_Zone_39);

            IGeographicCoordinateSystem gcsSys = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCS3Type.esriSRGeoCS_Xian1980);

 

            string[] ar_pts = gcsStr.Split(';');

            object tempType = Type.Missing;

            IPointCollection pPtCollection = new PathClass();

            for (int i = 0; i <= ar_pts.Length - 1; i++)

            {

                IPoint pt = new PointClass();

                pt.X = Convert.ToDouble(ar_pts[i].Split(',')[0]);

                pt.Y = Convert.ToDouble(ar_pts[i].Split(',')[1]);

                IGeometry geoGcs = (IGeometry)pt;

                geoGcs.SpatialReference = gcsSys;

                geoGcs.Project(pcsSys);

                IPoint ptAfter = geoGcs as IPoint;

                pPtCollection.AddPoint(ptAfter, ref tempType, ref tempType);

            }

 

            IGeometryCollection pGeoCollection = new PolylineClass();

            pGeoCollection.AddGeometry(pPtCollection as IGeometry, ref tempType, ref tempType);

            return pGeoCollection as IPolyline;

        }

备注:有坐标,无“度-带”,要确定度带。
解决方式:逐个试。某个“度-带”投影后 基本重合,即是。

 

常见细节:

(1) PCS: GK --> Xian80 3D  39Z 的featureClass, 使用3DAnalyst ceate TIN. TIN的坐标系统会变成 User_Defined Tranverse Mervator.

              对比显示featureclass的spatialReference和 TIN的,有此差异.

              显示,两者叠合

 * 各地图API坐标系统比较与转换;

 * WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,

 * 谷歌地图采用的是WGS84地理坐标系(中国范围除外);

 * GCJ02坐标系:即火星坐标系,是由中国国家测绘局制订的地理信息系统的坐标系统。由WGS84坐标系经加密后的坐标系。

 * 谷歌中国地图和搜搜中国地图采用的是GCJ02地理坐标系; BD09坐标系:即百度坐标系,GCJ02坐标系经加密后的坐标系;

 * 搜狗坐标系、图吧坐标系等,估计也是在GCJ02基础上加密而成的.


然后在csv中将其转化。

 

最后再在百度地图API上进行检验成功

 

#http://bbs.lbsyun.baidu.com/forum.php?mod=viewthread&tid=10923

#代码原地址

import csv

import string

import time

import math

 

#系数常量

a = 6378245.0

ee = 0.00669342162296594323

x_pi = 3.14159265358979324 * 3000.0 / 180.0;

 

#转换经度

def transformLat(lat,lon):

    ret = -100.0 + 2.0 * lat + 3.0 * lon + 0.2 * lon * lon + 0.1 * lat * lon +0.2 * math.sqrt(abs(lat))

    ret += (20.0 * math.sin(6.0 * lat * math.pi) + 20.0 * math.sin(2.0 * lat * math.pi)) * 2.0 / 3.0

    ret += (20.0 * math.sin(lon * math.pi) + 40.0 * math.sin(lon / 3.0 * math.pi)) * 2.0 / 3.0

    ret += (160.0 * math.sin(lon / 12.0 * math.pi) + 320 * math.sin(lon * math.pi  / 30.0)) * 2.0 / 3.0

    return ret

 

#转换纬度

def transformLon(lat,lon):

    ret = 300.0 + lat + 2.0 * lon + 0.1 * lat * lat + 0.1 * lat * lon + 0.1 * math.sqrt(abs(lat))

    ret += (20.0 * math.sin(6.0 * lat * math.pi) + 20.0 * math.sin(2.0 * lat * math.pi)) * 2.0 / 3.0

    ret += (20.0 * math.sin(lat * math.pi) + 40.0 * math.sin(lat / 3.0 * math.pi)) * 2.0 / 3.0

    ret += (150.0 * math.sin(lat / 12.0 * math.pi) + 300.0 * math.sin(lat / 30.0 * math.pi)) * 2.0 / 3.0

    return ret

 

#Wgs transform to gcj

def wgs2gcj(lat,lon):

    dLat = transformLat(lon - 105.0, lat - 35.0)

    dLon = transformLon(lon - 105.0, lat - 35.0)

    radLat = lat / 180.0 * math.pi

    magic = math.sin(radLat)

    magic = 1 - ee * magic * magic

    sqrtMagic = math.sqrt(magic)

    dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * math.pi)

    dLon = (dLon * 180.0) / (a / sqrtMagic * math.cos(radLat) * math.pi)

    mgLat = lat + dLat

    mgLon = lon + dLon

    loc=[mgLat,mgLon]

    return loc

 

#gcj transform to bd2

def gcj2bd(lat,lon):

    x=lon

    y=lat

    z = math.sqrt(x * x + y * y) + 0.00002 * math.sin(y * x_pi)

    theta = math.atan2(y, x) + 0.000003 * math.cos(x * x_pi)

    bd_lon = z * math.cos(theta) + 0.0065

    bd_lat = z * math.sin(theta) + 0.006

    bdpoint = [bd_lon,bd_lat]

    return bdpoint

 

#wgs transform to bd

def wgs2bd(lat,lon):

    wgs_to_gcj = wgs2gcj(lat,lon)

    gcj_to_bd = gcj2bd(wgs_to_gcj[0], wgs_to_gcj[1])

    return gcj_to_bd;

 

for i in range (3,4):

    n = str('2017.040'+ str(i)+'.csv')

    m = str('2017040' + str(i)+'.csv')

    csvfile = open(m,'w',encoding='UTF-8',newline='')

    nodes = csv.writer(csvfile)

    nodes.writerow(['md5','content','phone','conntime','recitime','lng','lat'])

    l=[]

    with open(n,newline='',encoding='UTF-8') as f:

        reader = csv.DictReader(f)

        for row in reader:

            if row['md5'] == 'md5':

原文地址:https://www.cnblogs.com/xinxihua/p/14497098.html