这是密码。我不懂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()
好吧,我希望假设你的代码比你展示给我们所有人的都多(事实上,有时没有更多的代码就很难回答这些问题),那么如果你已经声明了所有的变量,而不是在幕后,那么你所要做的就是像这样修复缩进:
如果您对python还很陌生,那么可能会阅读this,如果您仍然不确定,那么继续阅读this。我发现两者都很有帮助。你知道吗
你必须改变开始-它有for语句的地方。在python中,任何在结尾需要冒号的内容都必须缩进。你知道吗
最简单的方法是遍历for语句中的每一行,然后按TAB键。这将为您缩进代码。希望有帮助!你知道吗
我还观看或阅读了python的一个基本教程,它展示了缩进是如何工作的。你知道吗
相关问题 更多 >
编程相关推荐