Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to read text frome another file pythion

f = open("Myfile.txt", "r")
print(f.read())  #this is it if your using visual studio code.
					
                    # it may work on other things but try it.
                    
                    	#here is the other bit of code for the other file 
                        
                        
                        
#-------------------------------------------------------------------------
 									#this will overwrite anything in the text file!!!
                                    when you run the code
file1 = open("MyFile.txt","w+")  #this is the code to add text to the file 

file1.readline() 

file1.write("boy") #where you type in to add text to fiel


file1.close() # to close the file
Comment

PREVIOUS NEXT
Code Example
Python :: case statement in querset django 
Python :: register model in admin django 
Python :: pandas set condition multi columns 
Python :: pyautogui color 
Python :: give answer in 6 decimal python 
Python :: scroll horizontal excel 
Python :: django check if queryset is empty 
Python :: connection to server at "" (), port 5432 failed: timeout expired 
Python :: how to create a fixed size empty array in python 
Python :: numpy flatten 
Python :: ParserError: Error tokenizing data. C error: Expected 1 fields in line 6, saw 3 
Python :: python ndim 
Python :: left click pyautogui 
Python :: spacy nlp load 
Python :: python cv2 get image shape 
Python :: pandas shift column down 
Python :: pandas add column with constant value 
Python :: concatenate data vertically python 
Python :: drop column with nan values 
Python :: when was python developed 
Python :: install virtual environment python mac 
Python :: index of max value of sequence python 
Python :: s = 1 + 2 + ... + n in python 
Python :: pandas to latex 
Python :: round down python 
Python :: python ordered dictionary 
Python :: zip django template 
Python :: df reset index 
Python :: How to copy any text using python 
Python :: pandas replace string with another string 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =