December 2016
Beginner
197 pages
4h 18m
English
© Sanjib Sinha 2017
Sanjib Sinha, Beginning Ethical Hacking with Python, 10.1007/978-1-4842-2541-7_17
Sanjib Sinha1
(1)Howrah, West Bengal, India
Python has some built-in functions for dealing with files. You can open a file and read what is inside. You can write a file. That file could be a text file or a picture.
Each time we use the open() method and pass the mode as an argument. For reading a file we write “r” and for write we use “w”. Let us consider a code where in an object we read a file and write it on another file using another object in the next step.
<code>infile = open('files.txt', 'r')outfile = open('new.txt', 'w')for line in infile:print(line, file=outfile)print("Done")</code>
If we copy this way the ...
Read now
Unlock full access