在以下代码中,文件被正确创建和关闭,没有错误消息,但当它尝试写入文件时,没有任何反应。没有错误消息,也没有 0 写入文件:
if message.content == "MMO start":
dir = r'C:\\Users\\User\Desktop\MMOProfiles'
MessageAuthor = str(message.author)
newpath = os.path.join(dir,MessageAuthor)
doesExist = os.path.exists(newpath)
if doesExist == False:
await message.channel.send("Creating profile")
os.makedirs(newpath,1)
newpath = os.path.join(newpath,"Level.txt")
open(newpath,"x")
newpath.close()
open(newpath,"w")
newpath.write("0")
newpath.close()
if doesExist == True:
await message.channel.send("You already have a profile")
感谢所有帮助,谢谢。
慕村225694
相关分类