Reputation: 21
I would like to create a user json file and add the username to it. Everything works, but the only issue is that it keeps creating the json file in the parent directory of the source file, and not in the specific "file_location" path.
import json
user_name = input("Username: ")
#user_names is the directory I would like the file to be created in
file_location = "desktop/python_work/files_c10/user_names/"+user_name+".json"
print(f"{file_location}")
def add_user(file_location):
with open(file_location,'w') as f:
json.dump(user_name,f)
add_user(user_name)
Upvotes: 0
Views: 54