Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

path to create a text file in python

import os.path

save_path = 'C:/example/'

name_of_file = raw_input("What is the name of the file: ")

completeName = os.path.join(save_path, name_of_file+".txt")         

file1 = open(completeName, "w")

toFile = raw_input("Write what you want into the field")

file1.write(toFile)

file1.close()
Comment

path to create a text file in python

outFileName="F:folderfolderfilename.txt"
outFile=open(outFileName, "w")
outFile.write("""Hello my name is ABCD""")
outFile.close()
Comment

PREVIOUS NEXT
Code Example
Python :: python create file if doesnt exist 
Python :: pandas lamda column reference 
Python :: convert numpy array to cv2 image 
Python :: loop over twodimensional array python 
Python :: tensorflow bert implementation 
Python :: print statement in python 
Python :: pandas replace nan with mean 
Python :: cv2 imshow in colab 
Python :: python sum array 
Python :: python max key dictionary key getter 
Python :: filter query objects by date range in Django? 
Python :: python retry 
Python :: how to take input for list in python 
Python :: python pad with spaces 
Python :: python find object with attribute in list 
Python :: correlation between images python 
Python :: arrange array in ascending order python 
Python :: OneHotEncoder() 
Python :: tkinter allign 
Python :: pandas dataframe froms string 
Python :: replace all values in column pandas 
Python :: .argsort() python 
Python :: print dictionary of list 
Python :: solve ax=b python 
Python :: python if in range 
Python :: python to find the biggest among 3 numbers 
Python :: flask remove file after send_file 
Python :: how do you write a function in python 
Python :: isaplha in python 
Python :: how to create dictionary between two columns in python 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =