how to extract character from a text file in python code example
Example 1: how to get python to extract information from a text file
print("HEllo")
Example 2: how to read specific words from a file in python
fo = open("output.txt", "r+")
str = fo.readline()
str = str[7:11]
print("Read String is : ", str)
fo.close()
Example 3: Python program to extract characters from various text files and puts them into a list
import glob
ch_list=[]
file_list=glob.glob("*.py")
for file in file_list:
with open(file,'r') as f:
ch_list.append(f.read())
print(ch_list)
Example 4: how to read specific words from a file in python
fo = open("output.txt", "r+")
str = fo.readline()
str = str[7:11]
print "Read String is : ", str
fo.close()