我有一个名为“DistInt”的列表,其中包含强度值和地震事件的相应距离。有没有办法只打印列表中的特定行?
import math
import json
# Open JSON file
f = open("Path_to.geojson")
# Returns JSON object as a dictionary
data = json.load(f)
for feature in data['features']:
ml = float(feature['properties']['magnitude'])
h = float(feature['properties']['depth'])
i = 0
# Formula for working out Distances for MMI
Io = 1.5 * (ml - 1.7 * 0.4343 * math.log(h) + 1.4)
for i in range(1, 13, 1):
Iso = float(i)
a = (Io - Iso) / (1.8 * 0.4343)
d = math.exp(a)
d = d - 1
if d <= 0:
d = 0
else:
d = math.sqrt(h * h * d)
DistInt = [Iso, d]
print(DistInt)
将打印 DistInt 列表:
[1.0, 609.1896122140013]
[2.0, 321.0121765154287]
[3.0, 168.69332169329735]
[4.0, 87.7587868508665]
[5.0, 43.88709626561051]
[6.0, 17.859906969392682]
例如,我想打印行 - [2.0, 321.0121765154287]