0

您好,我正在尝试打开一个 .dat 文件并在其中写入一些单词。我从 pickle 导入了加载和转储,但是当我尝试转储时,它显示此错误:

TypeError: file must have a 'write' attribute

这是我的代码:

from pickle  import dump,load
def RempFichier(s):
    f=open(s,'wb')
    arret=""
    while not (arret=="f" or arret=="F" ):
        ch = sairAlph ()
        dump(f,ch)
        arret = str(input("si tu veut arreter taper f ou F sinon taper any key :"))


RempFichier("school-year\Dat_file\Lettre.dat")
4

0 回答 0