簡體   English   中英

如何修復代碼中的無效語法錯誤?

[英]How can I fix an invalid syntax error in my code?

所以我一直在嘗試運行這段代碼,但我不斷收到語法錯誤。 這是我嘗試使用以前的變量將它們轉換為另一個坐標系的部分。 任何幫助將不勝感激,謝謝!

import time as t
import datetime 
import math as m

start_time = datetime.datetime(2020, 7, 13, 0, 0).timestamp() 

print("This code gives the coordinates in xyz and Latitude and Longitude")
time_now = t.time() 
time_between = time_now - start_time
x = 5978.43 * m.cos(0.00129 * (time_between - 24066))
y = 4134.68 * m.cos(0.00129 * (time_between - 20190))
z = -4836.3 * m.cos(0.00129 * (time_between - 20581))
r = m.sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2) #I get the error here
theta = m.acos(z/r)
phi = m.atan(y/x)
latitude = (theta*180/m.pi - 90)* -1
print("The coordinates are:\n", "x = ", round(x, 2),"\n", "y = ", round(y, 2),"\n", "z = ", round(z, 2))
print("The latitude is: ", latitude, "and the Longitude is: ", phi)

您忘記關閉m.sqrt如下:

import time as t
import datetime 
import math as m

start_time = datetime.datetime(2020, 7, 13, 0, 0).timestamp() 

print("This code gives the coordinates in xyz and Latitude and Longitude")
time_now = t.time() 
time_between = time_now - start_time
x = 5978.43 * m.cos(0.00129 * (time_between - 24066))
y = 4134.68 * m.cos(0.00129 * (time_between - 20190))
z = -4836.3 * m.cos(0.00129 * (time_between - 20581))
r = m.sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2)) #I get the error here
theta = m.acos(z/r)
phi = m.atan(y/x)
latitude = (theta*180/m.pi - 90)* -1
print("The coordinates are:\n", "x = ", round(x, 2),"\n", "y = ", round(y, 2),"\n", "z = ", round(z, 2))
print("The latitude is: ", latitude, "and the Longitude is: ", phi)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM