Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. import sys
  2. import subprocess
  3. import json
  4.  
  5. if sys.platform == 'win32' or sys.platform == "cygwin":
  6. subprocess.Popen(['start', "C:"], shell= True)
  7. elif sys.platform == 'darwin' || sys.platform == "os2" || sys.platform == 'os2emx':
  8. subprocess.Popen(['open', "Macintosh HD"])
  9. elif sys.platform == "linux2":
  10. subprocess.Popen(['xdg-open', "/root"])
  11. else:
  12. try:
  13. subprocess.Popen(['xdg-open', "/root"])
  14. except OSError:
  15. print("You're using an unsupported operating system. Please manually navagate to your file explorer.")
  16.  
  17. print("Please input a full file path. (Use your file explorer to get the file path.)")
  18. filePath = input("Filepath: ")
  19.  
  20. print("Please input the file name. (Must be a json file.)")
  21. fileName = input("Filename: ")
  22.  
  23. isJson = fileName.split(".")
  24. if (len(isJson) != 2):
  25. fileName += ".json"
  26.  
  27. fullPath = filePath+"\\"+fileName
  28.  
  29. with open(fullPath, "r") as file:
  30. content = json.load(file)
  31. print("In the file ", fileName, "is:\n",content)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement