cycle

with open('james.txt') as jaf:
data = jaf.readline()
james = data.strip().split(',')
# james.sort()
with open('julie.txt') as jul:
data = jul.readline()
julie = data.strip().split(',')
# julie.sort()
with open('sarah.txt') as sar:
data = sar.readline()
sarahs=data.strip().split(',')
# sarahs.sort()
with open('mikey.txt') as mik:
data = mik.readline()
mikeys=data.strip().split(',')


=====    --等于

def getfile(filename):
try:
with open(filename) as f:
data = f.readline()
return (data.strip().split(','))
except IOError as ioerr:
print ('File error:' + str(ioerr))
return (None)
james = getfile('james.txt')
julie = getfile('julie.txt')
sarahs = getfile('sarah.txt')
mikeys = getfile('mikey.txt')


posted @ 2017-06-09 16:14  Alex_Footprint  阅读(198)  评论(0编辑  收藏  举报