1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
klemol [59]
3 years ago
9

You are utilizing the pickle.load function to load objects into a program from a file. However, your program raises an exception

as soon as the end of the file is reached. What must you do?
Social Studies
1 answer:
lesantik [10]3 years ago
6 0

Answer:

When the program raises an exception as soon as the end of the is reached, this exception makes the input process difficult. We have no specific or clear way to encounter the end of the file before the exception is raised.

So to resolve this Python's try except statement can be used. This statement catches the exception and enables the program to recover. We can construct an input file loop. This loop will keep loading objects until the end of the file is detected. Below is an example to load objects from the file into a new list.

lst=list()

fileObj = open("item.dat","rb")

while True:

try:

      item= pickle.load(fileObj)

      lst.append(item)

      except EOFError:

               fileObj.close()

               break

print(lst)

The file name is item.dat and new list is named as lst. When the end of the file is encountered EOFError is raised and except clause with EOFError closes the input file and breaks out of the loop.

You might be interested in
Which organisations in SA are dealing with corruption and fraud
I am Lyosha [343]

Aside from SAPS, The government has established National Anti-Corruption Forum which aims to:

<span>·         </span>Prevent and fight corruption

<span>·         </span>Upgrade protection for whistleblowers and witnesses

<span>·         </span>Blacklisting the corrupt individuals and businesses

<span>·         </span>Upgrade management policies and practices

<span>·         </span>Sustain professional ethics

<span>·         </span><span>Stakeholder partnerships</span>

8 0
3 years ago
Hellppppppppp!!!!meeeee
IgorLugansk [536]
You are right the U.S is in the Northern Hemisphere and the Western Hemisphere.
4 0
3 years ago
PLZ HELPP What is the name of the mass of air pollution that collects over the country China and other Asian nations?
AnnyKZ [126]

Answer:

Particulate matter (PM10 and PM2. ...

Ozone (O3)

Nitrogen dioxide (NO2)

Carbon monoxide (CO)

Sulphur dioxide (SO2)

Explanation:

I am not really sure but these are the most popular pollutant in Asia. thank you

8 0
3 years ago
A prominent sociologist wants to determine the sexual attitudes of women aged twenty-five to forty-five. The main question explo
Anuta_ua [19.1K]

Answer: Her hypothesis is absolutely wrong.

Explanation:

Now we need to get all the details regarding her survey.

SAMPLE SIZE : 400

TARGET GROUP :200

From target group:

COMPLETED FORMS : 78

That is 78/200 × 100%

Consequently, only 39% of her interviewees in her target group returns with their survey forms completed. This means that 61% of her target group cannot be put into the indices that would determine if her hypothesis is wrong or correct. Reason is, 61%(or 122 women) is too large a number to make assumptions for. They could be happy with the sexual performance of their partners or not.

8 0
3 years ago
The map shows Georgia’s counties. What does the map illustrate about Georgia’s counties?
adoni [48]
What map????????????????????????????????????????????????????????????????????????????????????????????????
4 0
3 years ago
Read 2 more answers
Other questions:
  • Based on this passage from the speech, what is President Reagan’s purpose?
    6·1 answer
  • Can children's cognitive development be accelerated with toys
    9·1 answer
  • One of the most difficult types of objections to overcome is one based on _____.
    10·1 answer
  • An I/O psychologist decides to use a "multiple uses test" to assess creativity. Individuals who identify more uses of a paper cl
    12·1 answer
  • Why is the price system a more efficient system for allocating scarce resources than by authoritarian means
    10·1 answer
  • Ft. Sumter is MOST significant for being ______________ A. the location of the end of the Civil War. B. destroyed by the Union w
    11·1 answer
  • 3. What is the role of executive departments and agencies?
    6·1 answer
  • WILL MARK BRAINLEST IF RIGHT
    9·2 answers
  • Can someone tell me what the USSR stands for ☭
    9·1 answer
  • Who led the Athenians after Pericles died from the plague?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!