diff --git a/kjg/python-the-hard-way/e15.py b/kjg/python-the-hard-way/e15.py new file mode 100644 index 0000000..c02e04e --- /dev/null +++ b/kjg/python-the-hard-way/e15.py @@ -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()) + diff --git a/kjg/python-the-hard-way/ex15_sample.txt b/kjg/python-the-hard-way/ex15_sample.txt new file mode 100644 index 0000000..8719939 --- /dev/null +++ b/kjg/python-the-hard-way/ex15_sample.txt @@ -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. diff --git a/kjg/python.org b/kjg/python.org index dffd17d..cf4f9ff 100644 --- a/kjg/python.org +++ b/kjg/python.org @@ -81,3 +81,6 @@ how to use key input with print how to use an argument when you run script **** ex14 how to use an argument with input +*** Python #3: +**** ex15 +How to use read function from file