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


Python py3compat.b方法代码示例

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


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

示例1: _read

# 需要导入模块: from Crypto.Util import py3compat [as 别名]
# 或者: from Crypto.Util.py3compat import b [as 别名]
def _read(self, N):
        # Starting with Python 3 open with buffering=0 returns a FileIO object.
        # FileIO.read behaves like read(2) and not like fread(3) and thus we
        # have to handle the case that read returns less data as requested here
        # more carefully.
        data = b("")
        while len(data) < N:
            try:
                d = self.__file.read(N - len(data))
            except IOError, e:
                # read(2) has been interrupted by a signal; redo the read
                if e.errno == errno.EINTR:
                    continue
                raise

            if d is None:
                # __file is in non-blocking mode and no data is available
                return data
            if len(d) == 0:
                # __file is in blocking mode and arrived at EOF
                return data

            data += d
        return data 
开发者ID:adde88,项目名称:hostapd-mana,代码行数:26,代码来源:posix.py

示例2: _read

# 需要导入模块: from Crypto.Util import py3compat [as 别名]
# 或者: from Crypto.Util.py3compat import b [as 别名]
def _read(self, N):
        # Starting with Python 3 open with buffering=0 returns a FileIO object.
        # FileIO.read behaves like read(2) and not like fread(3) and thus we
        # have to handle the case that read returns less data as requested here
        # more carefully.
        data = b("")
        while len(data) < N:
            try:
                d = self.__file.read(N - len(data))
            except IOError as e:
                # read(2) has been interrupted by a signal; redo the read
                if e.errno == errno.EINTR:
                    continue
                raise

            if d is None:
                # __file is in non-blocking mode and no data is available
                return data
            if len(d) == 0:
                # __file is in blocking mode and arrived at EOF
                return data

            data += d
        return data 
开发者ID:summerwinter,项目名称:SublimeRemoteGDB,代码行数:26,代码来源:posix.py


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