Skip to content

Instantly share code, notes, and snippets.

@ox1111
Last active April 2, 2019 00:47
Show Gist options
  • Save ox1111/dcc6a379ddbd48f0ebffb3ea4427c7b4 to your computer and use it in GitHub Desktop.
Save ox1111/dcc6a379ddbd48f0ebffb3ea4427c7b4 to your computer and use it in GitHub Desktop.
file write
# -*- coding: utf-8 -*-
#
# write by kyoung chip , jang
#
# python 3.6
#
#
class CFileWrite :
def __init__ ( self ) :
pass
def doWrite( self , root_dir , sub_dir , file_name , data ) :
filename = "%s\%s\%s" % ( root_dir , sub_dir , file_name )
print ( filename )
f = open(filename, 'w', encoding='UTF-8' )
f.write( str(data) )
f.close()
def doWrite( self , root_dir , sub_dir , file_name , vec=[] ) :
filename = "%s\%s\%s" % ( root_dir , sub_dir , file_name )
print ( filename )
f = open(filename, 'w', encoding='UTF-8' )
for i in vec:
f.write( str(i) )
f.close()
if __name__ == '__main__':
r = CFileWrite()
r.doWrite("d:\\test","test1","test.txt","aaa")
vec = []
vec.append("a")
vec.append("b")
vec.append("c")
r.doWrite("d:\\test","test1","test2.txt",vec)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment