This is the post in which you will learn about the Files in Python. Basically you can, by using this post learn how to create a file, write data and read data from it !
Things this code will do:
- Create a Folder Test
- Changes the Current Working Directory
- Creates a file as per your given name
- Stores the Data you give as input
- Shows the Data you gave as input
# Create a Directory and make it as working dir.
print "current working Dir: ",os.getcwd()
name=raw_input("Give the Name: ")
# Open a file and writing into it
fo = open(name, "w+")
fo.write(raw_input("Give the Data : "))
# Open a file and reading it
fo = open(name, "r+")
str = fo.read();
print "Read The Data :",str
Got problems ?
Ask us anything anytime, we will help you soon !
Latest posts by Bikash Panda (see all)
- OSMC on Raspberry PI with Setup and Control using Android App - July 7, 2017
- DHT12 Interfacing with Raspberry Pi using Pi4J - June 19, 2017
- Send data using MQTT from Raspberry Pi with JAVA - June 12, 2017