发布网友 发布时间:2022-04-25 12:55
共2个回答
热心网友 时间:2024-11-21 15:37
import math
import xlwings as xw
def zhuanhuan(arg1):
x,y = arg1.split(',')
x,y = float(x), float(y)
x -= 0.0065
y -= 0.006
x_pi = math.pi * 3000 / 180
z = math.sqrt(x**2 + y**2) - 0.00002 * math.sin(y * x_pi)
theta = math.atan2(y,x) - 0.000003 * math.cos(x * x_pi)
x1 = z * math.cos(theta)
y1 = z * math.sin(theta)
return str(x1) + ',' + str(y1)
app = xw.App()
workbook = app.books.open('转换坐标.xlsx')
sht = workbook.sheets('转换')
rng = sht.range('A2').expand('table')
data = rng.value
for i,x in enumerate(data):
data[i] = zhuanhuan(x)
sht.range('B2').options(transpose = True).value = data
热心网友 时间:2024-11-21 15:37
把所有行读完,放入列表。再计算,逐行写的入。