Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python read text file next line

filepath = 'Iliad.txt'
with open(filepath) as fp:
   line = fp.readline()
   cnt = 1
   while line:
       print("Line {}: {}".format(cnt, line.strip()))
       line = fp.readline()
       cnt += 1
Comment

python write text file on the next line

file = open("sample.txt", "w")
file.write("Hello
")
file.write("World
")
file.close()
Comment

PREVIOUS NEXT
Code Example
Python :: flask template split string 
Python :: list all files starting with python 
Python :: strip first occurence of substring python 
Python :: counter python 
Python :: debug mode: on flask pythin window 
Python :: django get form data from post 
Python :: push to pypi 
Python :: insert data in table python 
Python :: dimension of tensor 
Python :: remove last element from list python 
Python :: no module named pyinstaller 
Python :: sort columns dataframe 
Python :: python string: iterate string 
Python :: python timedelta to seconds 
Python :: python socket recv set timeout 
Python :: replace all values in column pandas 
Python :: outlier removal 
Python :: pdf to csv conversion 
Python :: python parentheses 
Python :: tensorflow adam 
Python :: install fasttext python 
Python :: convert ndarray to csr_matrix 
Python :: np where nan 
Python :: convert matplotlib figure to cv2 image 
Python :: python nonlocal 
Python :: print out a name in python 
Python :: Kill python background process 
Python :: spam python 
Python :: check if a string is float python 
Python :: poetry python download windows 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =