Horje
python write to file while reading Code Example
python write to file
file = open(“testfile.txt”,”w”) 
 
file.write(“Hello World”) 
file.write(“This is our new text file”) 
file.write(“and this is another line.”) 
file.write(“Why? Because we can.”) 
 
file.close() 
python write to file while reading
# writin content of one file to the other
with open("source.txt", "r") as inFile, open("target.txt", "w") as outFile:
    for line in inFile:
        print(line.strip("\n"), file=outFile)




Python

Related
presto sequence example date Code Example presto sequence example date Code Example
how to schedule python script in windows Code Example how to schedule python script in windows Code Example
grouped box plot in python Code Example grouped box plot in python Code Example
print python setencode Code Example print python setencode Code Example
How to print a variable in Python Code Example How to print a variable in Python Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7