Python Forum
HTML+CGI (if __name__ == '__main__')
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML+CGI (if __name__ == '__main__')
#6
I re-wrote the FiloeSearch method like this:

	def FileSearch(fileName,pattern):
		name_line = ""
		time_line = ""
		place_line = ""
		name, time, place = None;
		
		with open(fileName, "r+") as f:

		for line in f.readlines():
			name_line = re.search(pattern,lines)
			time_line = re.search("^time",lines)
			place_line = re.search("^[place]",lines)

			st = str.split(line,":")
			if name_line:
				name = st[1]
			
			if time_line:
				time = st[1]
				
			if place_line:
				place = st[1]
				

	##### I am not sure what you are doing here.... but your table only has 3 headings and you are sending 4 values back so I think you can get rid of the line number stuff
	### f.close(); done automatically by using with open()
		
		return(name, time, place)
	
You have 4 values being returned but are only using 3 of them. What results are you getting back when you run your code?
Reply


Messages In This Thread
HTML+CGI (if __name__ == '__main__') - by mahesh - Feb-19-2019, 11:49 AM
RE: HTML+CGI (if __name__ == '__main__') - by marienbad - Feb-19-2019, 04:20 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,759 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,422 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020