python question?

dict = {'Python' : '.py', 'C++' : '.cpp', 'Java' : '.java'}

f = open("dict.txt","w")

f.write( str(dict) )

f.close()

what does the f mean?

2 Answers

Relevance
  • ?
    Lv 5
    2 months ago

    f is a variable of file type.

    f -> file is opened - written to and closed.

    so you've loaded dict.txt from a device and then stored it in a memory variable called 'f' so you can manipulate its contents. The file handle gets locked during while accessing it to prevent errors and the handle is released once f.close() is executed.

  • EddieJ
    Lv 7
    2 months ago

    <f> is a reference to the file that was opened.

Still have questions? Get your answers by asking now.