本文整理汇总了Python中File.File.write方法的典型用法代码示例。如果您正苦于以下问题:Python File.write方法的具体用法?Python File.write怎么用?Python File.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File.File
的用法示例。
在下文中一共展示了File.write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import write [as 别名]
def write(self,of,interlaced = False):
"""Writes image to file."""
imagefile = File()
imagefile.make_IHDR(
self._width,
self._height,
self._bit_depth,
self._color_type
)
# handle special case blocks
if self._gamma != None:
imagefile.make_gAMA(self._gamma)
if self._color_type == 3:
imagefile.make_PLTE(self._palette)
if not self._background_color == None:
imagefile.make_bKGD(self._background)
if not self._simple_alpha == None:
imagefile.make_tRNS(self._simple_alpha, self._color_type)
# make data block
imagefile.make_IDAT(self._image)
# make text
if not self._text == None:
imagefile.make_tEXT(self._text)
# end file
imagefile.make_IEND()
imagefile.write(of)
return True
示例2: _save_report
# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import write [as 别名]
def _save_report(self, file_path, file_scan=None):
if self._report_ok is False:
return
content = ''
if file_scan is not None:
content += 'Filename: ' + file_scan + '\r\n'
content += 'MD5: ' + self._report['md5'] + '\r\n'
content += 'SHA1: ' + self._report['sha1'] + '\r\n'
content += 'SHA256: ' + self._report['sha256'] + '\r\n'
content += 'Permalink: ' + self._report['permalink'] + '\r\n'
content += '\r\n'
long_white_space = ' '
for key, value in self._report['scans'].items():
if value['detected'] is True:
content += key + ': ' + long_white_space[len(key):] + value['result'] + '\r\n'
target_file = File(file_path)
target_file.write(content)
del target_file