def write(self, text):
try:
with open(self.filepath, 'wt') as writer:
writer.write(text)
except UnicodeEncodeError as ue:
self.write_utf8(text) # attempt to write with utf-8 encoding
except Exception as e:
if DEBUG_FLAG:
sys.stderr.write("Naked Framework Error: Unable to write to requested file with the write() method (Naked.toolshed.file.py).")
raise e
#------------------------------------------------------------------------------
# [ write_as method ]
# text file writer that uses developer specified text encoding
# Tests: test_IO.py :: test_file_utf8_readas_writeas
#------------------------------------------------------------------------------
评论列表
文章目录