小编Nas*_*han的帖子

IO.UnsupportedOperation:不可写

我制作了一个程序,它在一个.txt文件中存储一个附有名称的分数。但是,我想然后打印附加到乐谱的名称的字母顺序。但是当我运行程序时,它出现了错误io.UnsupportedOperation: not writable Here my code:

            file = open(class_name , 'r')       #opens the file in 'append' mode so you don't delete all the information
            name = (name)
            file.write(str(name + " : " )) #writes the information to the file
            file.write(str(score))
            file.write('\n')
            lineList = file.readlines()
            for line in sorted(lineList):
                print(line.rstrip());
                file.close()
Run Code Online (Sandbox Code Playgroud)

python file

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

file ×1

python ×1