python 读取文件时,精确的保留数据

import numpy as np
import pandas as pd
point = pd.read_csv('waypoint21.csv')
with pd.option_context('display.precision', 12):  # 关键部分
    # print(point)
    B0 = np.double(point.loc[0, ['Lat']])
    L0 = np.double(point.loc[0, ['Lon']])
    # print(B0, L0)
    for i in range(len(point)):
        if i % 20 == 0:
            waypoint = point.loc[i, ["Lat", "Lon", "Heading"]].values.astype(float)
            lat = np.double(waypoint[[0]])
            lon = np.double(waypoint[[1]])
            x, y = transformation(lat, lon, B0, L0)
            line = "%s,%s,%s" % (x, y, waypoint[[2]][0])
            with open("b.csv", 'a+') as f:
                f.write(line + '\n')

 

你可能感兴趣的:(python 读取文件时,精确的保留数据)