Answers for "hwo to use input file in python function"

2

file input python

# import fileinput 
import fileinput 
  
# Using fileinput.input() method 
for line in fileinput.input(files ='gfg.txt'): 
    print(line)
Posted by: Guest on February-19-2021
0

how to write user input to a file in python

#Print User Input to A File
x = input("Enter blah : ")
y = open('C:UsersUSERNAMEDocumentsDoc1.txt', 'w')
y.write(x)

#Convert text to binary and then write to file
x = input("Enter blah : ")
y = open('C:UsersUSERNAMEDocumentsDoc1.txt', 'wb')
y.write(x)
Posted by: Guest on June-24-2020

Code answers related to "hwo to use input file in python function"

Python Answers by Framework

Browse Popular Code Answers by Language