Use the __methods__ technique that we saw earlier to see the methods of a file object. >>> myOutputFile = open('peak_deflection.txt','w')
>>> myOutputFile.__methods__
['close', 'fileno', 'flush', 'isatty', 'read',
'readinto', 'readline', 'readlines', 'seek', 'tell',
'truncate', 'write', 'writelines']
The The following example reads each line of a text file and changes the line to uppercase characters: # Read-only is the default access mode
>>> inputFile = open('foam.txt')
# You must declare write access
>>> outputFile = open('upper.txt','w')
>>> lines = inputFile.readlines()
>>> for line in lines:
... newLine = line.upper()
... outputFile.write(newLine)
...
>>> inputFile.close()
>>> outputFile.close()
The first line opens the input file; you do not need the | |||||||