while ループで値を渡すのに問題があります。以下にいくつかの疑似コードを配置してコーディングしましたが、結果を達成する方法はまだわかりませんが、可能であれば役立つように以下のコードを添付しました。while ループで値を渡しているエラー部分
まず、値の二重リストは次のとおりです。名前、東方、北方を指す
Stationlist = [['perth.csv','476050','7709929'],['sydney.csv','473791','7707713'],['melbourne.csv','46576','7691097']]
そして、ここに私が使用しているコードがあります:
Import math
global Eastingbase
global Northingbase
Eastingbase=476050
Northingbase= 7709929
Def calculateDistance (northingOne, eastingOne, northingTwo, eastingTwo):
Base =100000
deltaEasting = eastingTwo -eastingOne
deltaNorthing = northingTwo -northingOne
Distance = (deltaEasting**2 + deltaNorthing**2) **0.5
If Distance < Base:
Return Distance
Def Radius():
1000
L=0
while L <= Len(Stationlist):
if calculateDistance(Eastingbase, Northingbase, Stationlist(row L, column 2),Stationlist(row L, column 3)) < Radius:
Relevantfilename = StationList (row L, column 1)
print Relevantfilename
L = +1
私のエラーは、ステーション リストの値を while ループに渡し、ループを続行する方法がわからないことです。二重リスト内包表記、すなわち [0][1] を使用して名前を渡そうとしましたが、うまくいきません。また、L にプラス 1 を追加してもループが継続しないようです。1 つの行のすべての値を while ループに渡してテストする方法はありますか?? つまり、Perth.csv を Stationlist (行 L、列 1) に渡し、476050 を Stationlist (行 L、列 2) に渡し、7709929 を Stationlist (行 L、列 3) に渡します。
それが完了したら、メルボルンとシドニーのデータについて繰り返します