当前位置: 首页>>代码示例>>Python>>正文


Python FileIO.readall方法代码示例

本文整理汇总了Python中io.FileIO.readall方法的典型用法代码示例。如果您正苦于以下问题:Python FileIO.readall方法的具体用法?Python FileIO.readall怎么用?Python FileIO.readall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.FileIO的用法示例。


在下文中一共展示了FileIO.readall方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_zipdata

# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import readall [as 别名]
    def get_zipdata(self):
        cache_file_name = self.cache_filename
        stream = FileIO(cache_file_name, mode='w')
        zipfile = ZipFile(stream, 'w')
        self.write_zipfile(zipfile)
        zipfile.close()
        stream.close()

        stream = FileIO(cache_file_name, mode='r')
        zipdata = stream.readall()
        stream.close()
        remove(cache_file_name)
        return zipdata
开发者ID:syslabcom,项目名称:recensio.policy,代码行数:15,代码来源:export.py

示例2: FileDataReader

# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import readall [as 别名]
class FileDataReader(AbstractDataReader):
    """ A reader that can read data from a file
    """

    def __init__(self, filename):
        """
        :param filename: The file to read
        :type filename: str
        :raise spinnman.exceptions.SpinnmanIOException: If the file\
                    cannot found or opened for reading
        """
        try:
            self._fileio = FileIO(filename, "r")
        except IOError as e:
            raise SpinnmanIOException(str(e))

    def read(self, n_bytes):
        """ See :py:meth:`spinnman.data.abstract_data_reader.AbstractDataReader.read`
        """
        return bytearray(self._fileio.read(n_bytes))

    def readinto(self, data):
        """ See :py:meth:`spinnman.data.abstract_data_reader.AbstractDataReader.readinto`
        """
        return self._fileio.readinto(data)

    def readall(self):
        """ See :py:meth:`spinnman.data.abstract_data_reader.AbstractDataReader.readall`
        """
        return self._fileio.readall()

    def close(self):
        """ Closes the file

        :return: Nothing is returned:
        :rtype: None
        :raise spinnman.exceptions.SpinnmanIOException: If the file\
                    cannot be closed
        """
        try:
            self._fileio.close()
        except IOError as e:
            raise SpinnmanIOException(str(e))
开发者ID:Scaatis,项目名称:SpiNNMan,代码行数:45,代码来源:file_data_reader.py

示例3: load_from_file

# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import readall [as 别名]
 def load_from_file(filename):
     f = FileIO(filename, 'rb')
     data = f.readall()
     return ByteArray(data)
开发者ID:Tony-Wang,项目名称:YaYaNLP,代码行数:6,代码来源:bytearray.py

示例4: len

# 需要导入模块: from io import FileIO [as 别名]
# 或者: from io.FileIO import readall [as 别名]
"""

import sys
import io
from io import FileIO

inputFileName = sys.argv[1]
outputFileName = sys.argv[2]
nInLine = 10
if len(sys.argv) >= 4:
    nInLine = int(sys.argv[4])

inputStream = FileIO(inputFileName, "r")
outputFile = open(outputFileName, "w")

inputData = inputStream.readall()
inputStream.close()

outputStr = ""

n = 0
for x in inputData:
    outputStr += str(ord(x)).rjust(3) + ", "
    n += 1
    if n >= nInLine:
        outputStr += "\n"
        n = 0

outputFile.write(outputStr)
outputFile.close()
开发者ID:fiftin,项目名称:bin2array,代码行数:32,代码来源:bin2array.py


注:本文中的io.FileIO.readall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。