Domanda

Sto usando NetBeans per scrivere Python, e l'ho avuto in modo che iopotrebbe aggiungere un file (in Eclipse) con file = open('dir\file', 'a') in modo da poter aggiungere un file, ma ottengo questo:

aifc.Error: mode must be 'r', 'rb', 'w', or 'wb'
.

Non voglio dover leggere il file, salvare a file o file temp e quindi riscrivere.Cosa sta succedendo?

Nota: ottengo la stessa cosa nel prompt dei comandi, che mi sembra strano per me.

Inoltre, so che il mio interprete è configurato correttamente e tutto è nella cartella Python34 (cioè python34\Lib\site-packages)

Messaggio di errore completo sulla corsa:

Running...
Traceback (most recent call last):
  File "G:\Prog\PythonCurrent\RadioDB\src\radiodb.py", line 122, in <module>
    main()
  File "G:\Prog\PythonCurrent\RadioDB\src\radiodb.py", line 43, in main
    lineTypesFile = open('{}/Desktop/GPS Line Types.txt'.format(home), 'a')
  File "c:\Python34\lib\aifc.py", line 891, in open
    raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
aifc.Error: mode must be 'r', 'rb', 'w', or 'wb'
.

È stato utile?

Soluzione

L'errore proviene da aifc Module. aifc.open supporta solo le modalità r, rb, w e wb Modalità.Stai chiamando from aifc import * da qualche parte nel tuo script?Se è così, non farlo!È ombreggiato il open integrato con aifc.open.Importare solo le funzioni necessarie da aifc.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top