Which of the following error is returned by the given code ?
f = open("test.txt","w") f.write(345)
निम्न में से कौन सी एरर दिए गए कोड द्वारा प्रस्तुत किया जाता है?
TypeError: write() argument must be str, not int
In Python, the "w" (write) mode is used to open a file for writing. If the file specified in the open function does not exist, it will create a new file. If the file already exists, opening it in write mode will truncate the file to zero length, effectively erasing its content.
To read the entire content of a file in Python, you can use the read() method on the file object.
Example:
f = open("filename.txt", "r") # Open the file in read modecontent = f.read() # Read the entire content of the filef.close() # Close the fileprint(content) # Print the content of the file
what is 'f' in the following statement?
f=open("Data.txt","r")
निम्नलिखित स्टेटमेंट में 'f ' क्या है?