Write Python Code to Create file to Write The contents to file at the Run Time
filename =
input("Enter name of file: ")
contents =
input("Enter contents of file: ")
with open(filename, 'w')
as f:
f.write(contents)
print("File created
successfully.")
print("This is your
file")
print(contents)
Output:
Enter name of file:
myfile
Enter contents of file:
This is file handling class. Python programming
File created
successfully.
This is your file
This is file handling
class. Python programming
0 टिप्पण्या
कृपया तुमच्या प्रियजनांना लेख शेअर करा आणि तुमचा अभिप्राय जरूर नोंदवा. 🙏 🙏