本文整理汇总了Python中FileIO.write方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.write方法的具体用法?Python FileIO.write怎么用?Python FileIO.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileIO
的用法示例。
在下文中一共展示了FileIO.write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileIO_test
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import write [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: login
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import write [as 别名]
def login(home_path, today, file_write = 0):
try :
(ok, login_l, other_l) = login_list(os.path.join(home_path,'.ac_info'))
if not ok : return (0, home_path + ' ' + l)
#(1, [('20051010', '20051010'), ('20051012', '20051015')], [])
(ok, r) = _login(login_l, today)
if not ok :
return (0, r)
login_l2 = login_format(r)
reply = join_list(login_l2, other_l)
i = len(login_l2) - len(login_l)
log = '%s %d row added' % ( os.path.join(home_path,'.ac_info'), i)
if( not os.path.exists(home_path)) :
return (0, reply, home_path + ' not exists')
if (file_write) :
FileIO.write(os.path.join(home_path,'.ac_info'), reply)
return (1, reply, log)
except :
t, v, tb = sys.exc_info()
print 'login exception... (%s:%s)' % (t, v)
return (0, log , log)
示例3: writeCustomToFile
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import write [as 别名]
def writeCustomToFile(customPrograms, customName):
'''Store custom application information'''
tempDir = tempfile.gettempdir()
tempLocation = os.path.join(tempDir,'AssetManagerTemp')
tempLocation = os.path.join(tempLocation,'CustomMenuItems.ini')
data = '#Custom Application:'
section = ['CustomPrograms', 'CustomName']
key = ['Programs', '\n', 'Names']
value = []
for item in customPrograms:
value.append(item)
value.append('\n')
for item in customName:
value.append(item)
data = FileIO.build(data, section, key, value)
FileIO.write(data, tempLocation)
示例4: touch_ktf_notify
# 需要导入模块: import FileIO [as 别名]
# 或者: from FileIO import write [as 别名]
def touch_ktf_notify(t) :
try :
(id, level , s_type, email_list) = t
ok , path = home_fullpath(id)
if not os.path.exists(path) : DirUtil.make_dirs(path)
l = []
l.append("level=" + level + "&type=" + s_type)
for email in email_list :
l.append(email)
l.sort()
FileIO.write(os.path.join(path, '.ktf_notify'), l)
return (1, os.path.join(path, '.ktf_notify'))
except :
t, v, tb = sys.exc_info()
log = 'touch_ktf_notify(%s:%s)' % (t, v)
return (0, log)