简体   繁体   中英

Python/Discord — When i try to make a folder it is in my desktop instead of the designated folder

This is the current code:

   if message.content == "MMO start":
        dir=(r"C:\\Users\\User\Desktop\MMMOProfiles")
        file = str(message.author)
        path = os.path.join(dir,file)
        isExist = os.path.exists(path)
        if isExist == True:
            await message.channel.send("You already have a profile")
        elif isExist == False:
            await message.channel.send("Creating profile")
            file2 = str(message.author)
            dir =(r"C:\\Users\\User\Desktop\MMOProfiles")
            os.mkdir(file2)

When I try to make it create the folder though it is in the desktop instead of the folder on the desktop.

This code will check if the folder in the desktop, if not it will create the new folder:

newpath = r'C:\Users\mooqa\Desktop\ss' 
if not os.path.exists(newpath):
os.makedirs(newpath)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM