當前位置: 首頁>>代碼示例>>Python>>正文


Python FileIO.write方法代碼示例

本文整理匯總了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
開發者ID:iloveaired,項目名稱:nbviewer,代碼行數:35,代碼來源:lib_test.py

示例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)
開發者ID:iloveaired,項目名稱:nbviewer,代碼行數:37,代碼來源:AQUtil.py

示例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)
開發者ID:burninghelix123,項目名稱:AssetManager,代碼行數:18,代碼來源:OpenAsset.py

示例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)
開發者ID:iloveaired,項目名稱:nbviewer,代碼行數:24,代碼來源:KTFUtil.py


注:本文中的FileIO.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。