Queer European MD passionate about IT

extensions.py 505 B

12345678910111213141516171819202122
  1. extensions = {
  2. ".gif": "image/gif",
  3. ".jpg": "image/jpeg",
  4. ".jpeg": "image/jpeg",
  5. ".png": "image/png",
  6. ".pdf": "application/pdf",
  7. ".txt": "text/plain",
  8. ".zip": "application/zip"
  9. }
  10. def main():
  11. file_name = input("Enter file name:\t\t").lower().strip()
  12. for extension, mime in extensions.items():
  13. if file_name.endswith(extension):
  14. print(mime)
  15. break
  16. else:
  17. print("application/octet-stream")
  18. if __name__ == "__main__":
  19. main()