Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to read the first line in a file python

f = open("test.txt", 'r')
variable = f.readline(1)
print(variable)
Comment

get first line of file python

with open('myfile.txt') as f:
    first_line = f.readline()
Comment

PREVIOUS NEXT
Code Example
Python :: python remove last element from list 
Python :: python plot 
Python :: how to delete all item in treeview tkinter 
Python :: python get list of files in directory 
Python :: sorting numbers in python without sort function 
Python :: 2 variables with statement python 
Python :: measure cell execution time in ipython notebook 
Python :: create age-groups in pandas 
Python :: how to use dictionary comprehension to make a dictionary for some names of a list in python 
Python :: create bigram in python 
Python :: sort dict by value 
Python :: count lines in file python 
Python :: tdmq python 
Python :: python change terminal name 
Python :: remove spaces from string python 
Python :: python check if string is in input 
Python :: float to percentage python 
Python :: user group template tag django 
Python :: relu function python 
Python :: orderd set in python 
Python :: python convert number in array to integer 
Python :: roots of quadratic equation in python 
Python :: handle queries in listview django 
Python :: create an environment in conda 
Python :: how to sum only the even values in python 
Python :: numpy roundup to nearest 5 
Python :: python push to dataframe pandas 
Python :: Converting List to Dataframe Using zip() function 
Python :: how to import include in django 
Python :: how to make label background transparent in tkinter 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =