python basis of a day15 jobs

3. The process file, the user specifies the contents to find the file and the file contains the content to find each row to the screen 
DEF check_file (filename, AIM):
with Open (filename, encoding = 'UTF-. 8') AS f: # handle: handler, operator files, a file handle
for I in F:
IF I in AIM:
the yield I

G = check_file ( 'review. 1 .py.', 'producer')
for I in G:
Print (I .strip ())

4. sketch generator reads from the file, before each coupled to read the contents of '***' after then returned to the user.
check_file DEF (filename):
with Open (filename, encoding = 'UTF-. 8') AS F: # Handle: handler, operator files, a file handle
for I in F:
the yield '***' + I

for I in check_file ( '1. review .py'):
Print (i.strip ())

Guess you like

Origin www.cnblogs.com/wang-tan/p/11073599.html