convert_ll_dec.py 424 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python3
  2. import sys
  3. def error():
  4. print("d:NO_DATA")
  5. print("m:NO_DATA")
  6. print("s:NO_DATA")
  7. exit(1)
  8. if len(sys.argv) < 2:
  9. error()
  10. try:
  11. deg = float(sys.argv[1])
  12. except:
  13. print("Can't convert it to float")
  14. error()
  15. m, s = divmod(abs(deg)*3600, 60)
  16. d, m = divmod(m, 60)
  17. if deg < -1:
  18. d = -d
  19. d, m = int(d), int(m)
  20. print("d:"+str(d))
  21. print("m:"+str(m))
  22. print("s:{:.4f}".format(s));