I need to save a folder called D:\MyPc if the hostname is MyPc
name_file = open("D:/Others/name.txt" , "r")
data = name_file.readline()
name_file.close()
print(os.path.join("D:\", data))
the output is D:
MyPc
To check the hostname: How can I use Python to get the system hostname?
Also, there is an error in your code. Change the last line to have double backslash in string:
print(os.path.join("D:\\", data))