I`m working with text file, and I want to read a text file line by line, and if line start with # I want to write before it * for example I have this file:
hello
world
#house
tree
I want it to be:
hello
world
*#house
tree
and if it easier I dont mind to do: *house or instead all the line to do that:
hello
world
*
tree
Do you know how to do it? thank:)
thanks for your replies:) I understood that the best way is to Read the file line by line and write the modified version out into a new file. Then close and remove the old file and rename the new one. have a nice day:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.