當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。