Extracting the Ingredients from a Recipe with Regular Expressions,,import sysim
Extracting the Ingredients from a Recipe with Regular Expressions,,import sysim
import sysimport repat = r'<ingredients>((.|\n)*?)</ingredients>'filename = sys.argv[1]data = open(filename).read()m = re.search(pat,data)if not m: print 'No ingredients found' print sys.exit(1)ingredients = m.group(1)pat = r'<item\s.*?>(.*?)</item>'all = re.findall(pat,ingredients)for item in all: print item
- for statement calls iter() on the container object,ite
- Button mouse action: mouse in, out and rollover,mouser
- Warning bmp on a Label,warninglabel,from Tkinter
- Make default not global,makeglobal,def f(x, y=N
- Passing value or passing address,passingvalue,def try_
- String replacement,stringreplacement,S = 'spammy'
热门文章:
相关内容
- for statement calls iter() on the container object,itercontainer,fo
- Button mouse action: mouse in, out and rollover,mouserollover,# But
- Warning bmp on a Label,warninglabel,from Tkinter
- Make default not global,makeglobal,def f(x, y=N
- Passing value or passing address,passingvalue,def try_to_c
- String replacement,stringreplacement,S = 'spammy'
- Specify Documentation Strings during function definition,,# Here is
- Product in Python,productinpython,print '6 * 3
- A tuple is an immutable list,tupleimmutable,t = ('a', 'b
- Demonstrates the range() function,demonstratesrange,print 'Count
评论关闭