[Python #2] create e15.py
This commit is contained in:
parent
5b5bfe07ca
commit
8be2fe479d
3 changed files with 25 additions and 0 deletions
19
kjg/python-the-hard-way/e15.py
Normal file
19
kjg/python-the-hard-way/e15.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
from sys import argv
|
||||||
|
|
||||||
|
script, filename = argv
|
||||||
|
|
||||||
|
txt = open(filename)
|
||||||
|
|
||||||
|
|
||||||
|
print(f"Here's your file {filename}: ")
|
||||||
|
print(txt.read())
|
||||||
|
|
||||||
|
txt.close()
|
||||||
|
|
||||||
|
print("Type the filename again : ")
|
||||||
|
file_again = input("> ")
|
||||||
|
|
||||||
|
txt_again = open(file_again)
|
||||||
|
|
||||||
|
print(txt_again.read())
|
||||||
|
|
3
kjg/python-the-hard-way/ex15_sample.txt
Normal file
3
kjg/python-the-hard-way/ex15_sample.txt
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
This is stuff I typed into a file.
|
||||||
|
It is really cool stuff .
|
||||||
|
Lots and lots of fun to have in here.
|
|
@ -81,3 +81,6 @@ how to use key input with print
|
||||||
how to use an argument when you run script
|
how to use an argument when you run script
|
||||||
**** ex14
|
**** ex14
|
||||||
how to use an argument with input
|
how to use an argument with input
|
||||||
|
*** Python #3:
|
||||||
|
**** ex15
|
||||||
|
How to use read function from file
|
||||||
|
|
Loading…
Add table
Reference in a new issue