Skip to main content
adicionou 175 caracteres ao conteúdo
Fonte Link

----att

continuo com o problema no codigo: import pickle

arq = open('testePickle.dat','wb')

variavel = 0

pickle.dump(variavel,arq)

----att

continuo com o problema no codigo: import pickle

arq = open('testePickle.dat','wb')

variavel = 0

pickle.dump(variavel,arq)
adicionou 292 caracteres ao conteúdo
Fonte Link
import pickle

arqT = open('turmaAlunos.dat', 'ab') choice = 'n'

while True: nome = input('Digite nome do aluno') pickle.dump(nome,arqT)


arqT = open('turmaAlunos.dat', 'ab')
choice = 'n'


while True:
    nome = input('Digite nome do aluno')
    pickle.dump(nome,arqT)

    if name == '':
        while True:
            choice = input("Voce quer mesmo terminar? [s/n]")
            if choice == 's':
                break
            elif choice == 'n':
                break
            else:
                print("Opção inválida")
                continue

        if choice == 's':
            break
        else:
            continue

    matOk = False
    while not matOk:
        matricula = input('Digite a matricula do aluno:')
        if len(matricula) < 6:
            print('Matricula inválida, digite novamente')
        else:
            matOk = True

    notas = []

    print("Digite as notas do alunos:\n")
    for i in range(3):
        notas.append(int(input()))

    for i in range(len(notas)):
        notas[i] = int(notas[i])

    pickle.dump(notas,arqT)

arqT.close()

arqT.close()

----Retorno:

/usr/bin/python3.6 /../PycharmProjects/aval1/pickle.py Digite nome do aluno etc Digite nome do aluno etc Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 26, in import cPickle as pickle ModuleNotFoundError: No module named 'cPickle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 36, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Original exception was: Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Já aproveitando, como eu formato um código no stackoverflow?

/usr/bin/python3.6 /../PycharmProjects/aval1/pickle.py
Digite nome do aluno etc
Traceback (most recent call last):
  File "../PycharmProjects/aval1/pickle.py", line 1, in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 26,                in <module>
    import cPickle as pickle
ModuleNotFoundError: No module named 'cPickle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in        apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in     <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in     <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in     <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 36,     in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'

Original exception was:
Traceback (most recent call last):
  File "../PycharmProjects/aval1/pickle.py", line 1, in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'
import pickle

arqT = open('turmaAlunos.dat', 'ab') choice = 'n'

while True: nome = input('Digite nome do aluno') pickle.dump(nome,arqT)

if name == '':
    while True:
        choice = input("Voce quer mesmo terminar? [s/n]")
        if choice == 's':
            break
        elif choice == 'n':
            break
        else:
            print("Opção inválida")
            continue

    if choice == 's':
        break
    else:
        continue

matOk = False
while not matOk:
    matricula = input('Digite a matricula do aluno:')
    if len(matricula) < 6:
        print('Matricula inválida, digite novamente')
    else:
        matOk = True

notas = []

print("Digite as notas do alunos:\n")
for i in range(3):
    notas.append(int(input()))

for i in range(len(notas)):
    notas[i] = int(notas[i])

pickle.dump(notas,arqT)

arqT.close()

----Retorno:

/usr/bin/python3.6 /../PycharmProjects/aval1/pickle.py Digite nome do aluno etc Digite nome do aluno etc Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 26, in import cPickle as pickle ModuleNotFoundError: No module named 'cPickle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 36, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Original exception was: Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Já aproveitando, como eu formato um código no stackoverflow?

import pickle

arqT = open('turmaAlunos.dat', 'ab')
choice = 'n'


while True:
    nome = input('Digite nome do aluno')
    pickle.dump(nome,arqT)

    if name == '':
        while True:
            choice = input("Voce quer mesmo terminar? [s/n]")
            if choice == 's':
                break
            elif choice == 'n':
                break
            else:
                print("Opção inválida")
                continue

        if choice == 's':
            break
        else:
            continue

    matOk = False
    while not matOk:
        matricula = input('Digite a matricula do aluno:')
        if len(matricula) < 6:
            print('Matricula inválida, digite novamente')
        else:
            matOk = True

    notas = []

    print("Digite as notas do alunos:\n")
    for i in range(3):
        notas.append(int(input()))

    for i in range(len(notas)):
        notas[i] = int(notas[i])

    pickle.dump(notas,arqT)

arqT.close()

----Retorno:

/usr/bin/python3.6 /../PycharmProjects/aval1/pickle.py
Digite nome do aluno etc
Traceback (most recent call last):
  File "../PycharmProjects/aval1/pickle.py", line 1, in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 26,                in <module>
    import cPickle as pickle
ModuleNotFoundError: No module named 'cPickle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in        apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in     <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in     <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in     <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 36,     in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'

Original exception was:
Traceback (most recent call last):
  File "../PycharmProjects/aval1/pickle.py", line 1, in <module>
    import pickle
  File "../PycharmProjects/aval1/pickle.py", line 9, in <module>
    pickle.dump(nome,arqT)
AttributeError: module 'pickle' has no attribute 'dump'
Fonte Link

Problema na biblioteca Pickle em Python

Então, to tentando aplicar o seguinte código, mas o compilador ta me devolvendo seguinte problema, não consigo pensar em nada que não seja algum problema de instalação, mas obtive esse problema em dois computadores diferentes com o mesmo código:

import pickle

arqT = open('turmaAlunos.dat', 'ab') choice = 'n'

while True: nome = input('Digite nome do aluno') pickle.dump(nome,arqT)

if name == '':
    while True:
        choice = input("Voce quer mesmo terminar? [s/n]")
        if choice == 's':
            break
        elif choice == 'n':
            break
        else:
            print("Opção inválida")
            continue

    if choice == 's':
        break
    else:
        continue

matOk = False
while not matOk:
    matricula = input('Digite a matricula do aluno:')
    if len(matricula) < 6:
        print('Matricula inválida, digite novamente')
    else:
        matOk = True

notas = []

print("Digite as notas do alunos:\n")
for i in range(3):
    notas.append(int(input()))

for i in range(len(notas)):
    notas[i] = int(notas[i])

pickle.dump(notas,arqT)

arqT.close()

----Retorno:

/usr/bin/python3.6 /../PycharmProjects/aval1/pickle.py Digite nome do aluno etc Digite nome do aluno etc Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump' Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 26, in import cPickle as pickle ModuleNotFoundError: No module named 'cPickle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook from apport.fileutils import likely_packaged, get_recent_crashes File "/usr/lib/python3/dist-packages/apport/init.py", line 5, in from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 36, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Original exception was: Traceback (most recent call last): File "../PycharmProjects/aval1/pickle.py", line 1, in import pickle File "../PycharmProjects/aval1/pickle.py", line 9, in pickle.dump(nome,arqT) AttributeError: module 'pickle' has no attribute 'dump'

Já aproveitando, como eu formato um código no stackoverflow?