Question 1:
write a program to find the given string in the root directory that contains a text file
1. In a recursive manner (case in sensitive )
2. only in the root directory
use command line arguments.
program_name -ri string root_dir (recursive)
program_name -si string root_dir (root director )
The output which file and line contains the string
import os.path
save_path = input()
name_of_file = input()
completeName = os.path.join(save_path, name_of_file+".txt")
file1 = open(completeName, "w")
toFile = input()
file1.write(toFile)
file1.close()
Comments
Leave a comment