本文整理汇总了Python中FileIO.read方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.read方法的具体用法?Python FileIO.read怎么用?Python FileIO.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileIO_test
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import read [as 别名]
def FileIO_test():
data ="1\n2\n3\n4\n"
rt = FileIO.write('WRITE_TEST', data, 'w')
assert(rt == 0)
c_list = []
(rt, c_list) = File.read("WRITE_TEST", 3)
assert(rt == 0)
assert(len(c_list) == 3)
# 0 이면 all line -> list 로
(rt, c_list) = FileIO.read("WRITE_TEST", 0)
assert(rt == 0)
assert(len(c_list) == 4)
list = []
list.append('AA')
list.append('BB')
rt = FileIO.write('TEST01', list)
assert(rt == 0)
(rt, c_list) = FileIO.read("TEST01", 2)
assert(rt == 0)
assert(len(c_list) == 2)
return
示例2: ktf_notify
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import read [as 别名]
def ktf_notify(id) :
try :
ok , path = home_fullpath(id)
if not os.path.exists(os.path.join(path, '.ktf_notify')) : return (0, '','',[])
ok, lines = FileIO.read(os.path.join(path, '.ktf_notify'))
if not ok : return (0, '','',[])
hash = TokenList.decode(lines[0].rstrip())
email_list = []
for line in lines[1:] :
email_list.append(line.rstrip())
return (1, hash['level'], hash['type'] , email_list)
except :
t, v, tb = sys.exc_info()
log = 'ktf_notify(%s:%s)' % (t, v)
print log
return (0, '','',[])
示例3: login_list
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import read [as 别名]
def login_list(file) :
try :
(ok, lines) = FileIO.read(file)
reply = []
other_l = []
for line in lines :
try :
#NOT FOUND
if line.find('LOGIN\t') == -1 :
other_l.append(line.rstrip())
continue
# LOGIN \t A:B
(dummy, login_date) = line.rstrip().split('\t')
(sdate, edate) = login_date.split(':')
reply.append((sdate, edate))
except :
pass
return (1, reply, other_l)
except :
t, v, tb = sys.exc_info()
log = 'login list ex... (%s:%s)' % (t, v)
return (0, log ,log)