ここにコードです。私のpythonを知っていると私はブロックを定義するには何の括弧がない、Pythonではループ予期しないインデントエラー - 誰か他のコードを微調整しようとしています
for poke in visible:
other = LatLng.from_degrees(poke.Latitude, poke.Longitude)
diff = other - origin
# print(diff)
difflat = diff.lat().degrees
difflng = diff.lng().degrees
direction = (('N' if difflat >= 0 else 'S') if abs(difflat) > 1e-4 else '') + (('E' if difflng >= 0 else 'W') if abs(difflng) > 1e-4 else '')
print("(%s) %s is visible at (%s, %s) for %s seconds (%sm %s from you)" % (poke.pokemon.PokemonId, pokemons[poke.pokemon.PokemonId - 1]['Name'], poke.Latitude, poke.Longitude, poke.TimeTillHiddenMs/1000, int(origin.get_distance(other).radians * 6366468.241830914), direction))
with open("test.txt", "a") as myfile:
myfile.write("(%s) %s is visible at (%s, %s) for %s seconds (%sm %s from you)" % (poke.pokemon.PokemonId, pokemons[poke.pokemon.PokemonId - 1]['Name'], poke.Latitude, poke.Longitude, poke.TimeTillHiddenMs/1000, int(origin.get_distance(other).radians * 6366468.241830914), direction))
myfile.write("\n")
myfile.flush()
コードは実際にどのように見えますか? – IanAuld
これはほんの一部です。質問は簡単です。 – MonsterMMORPG
最初のforループはインデントしないでください。また、その本体に追加のインデントが必要です。文脈がなければ、伝えるのは不可能です。トレースバックを含む完全なエラーメッセージを追加する必要があります。 –