當前位置: 首頁>>代碼示例>>Python>>正文


Python builtins.int方法代碼示例

本文整理匯總了Python中builtins.int方法的典型用法代碼示例。如果您正苦於以下問題:Python builtins.int方法的具體用法?Python builtins.int怎麽用?Python builtins.int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在builtins的用法示例。


在下文中一共展示了builtins.int方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _strict_call

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def _strict_call(self, value):
        try:

            # We check if we can convert the value using the current function
            new_value = self.func(value)

            # In addition to having to check whether func can convert the
            # value, we also have to make sure that we don't get overflow
            # errors for integers.
            if self.func is int:
                try:
                    np.array(value, dtype=self.type)
                except OverflowError:
                    raise ValueError

            # We're still here so we can now return the new value
            return new_value

        except ValueError:
            if value.strip() in self.missing_values:
                if not self._status:
                    self._checked = False
                return self.default
            raise ValueError("Cannot convert string '%s'" % value)
    # 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:27,代碼來源:_iotools.py

示例2: all2datetime

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def all2datetime(arg):
    """Return a datetime object from an int (timestamp) or an iso
    formatted string '%Y-%m-%d %H:%M:%S'.

    """
    if isinstance(arg, datetime.datetime):
        return arg
    if isinstance(arg, basestring):
        for fmt in ['%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M:%S.%f',
                    '%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%S.%f']:
            try:
                return datetime.datetime.strptime(arg, fmt)
            except ValueError:
                pass
        raise ValueError('time data %r does not match standard formats' % arg)
    if isinstance(arg, (int_types, float)):
        return datetime.datetime.fromtimestamp(arg)
    raise TypeError("%s is of unknown type." % repr(arg)) 
開發者ID:cea-sec,項目名稱:ivre,代碼行數:20,代碼來源:utils.py

示例3: change_rpcinfo

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def change_rpcinfo(table):
    """Adapt structured output generated by the "rpcinfo" Nmap script. The
structured output uses program numbers (hence, data) as keys, which is
undesirable in the databases. Also, some elements can be converted to
integers.

New in SCHEMA_VERSION == 12.

    """
    result = []
    for program, protores in viewitems(table):
        for proto, data in viewitems(protores):
            data["program"] = int(program)
            data["protocol"] = proto
            try:
                data['port'] = int(data['port'])
            except (KeyError, ValueError):
                pass
            result.append(data)
    return result 
開發者ID:cea-sec,項目名稱:ivre,代碼行數:22,代碼來源:xmlnmap.py

示例4: _set_array_types

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def _set_array_types():
    ibytes = [1, 2, 4, 8, 16, 32, 64]
    fbytes = [2, 4, 8, 10, 12, 16, 32, 64]
    for bytes in ibytes:
        bits = 8*bytes
        _add_array_type('int', bits)
        _add_array_type('uint', bits)
    for bytes in fbytes:
        bits = 8*bytes
        _add_array_type('float', bits)
        _add_array_type('complex', 2*bits)
    _gi = dtype('p')
    if _gi.type not in sctypes['int']:
        indx = 0
        sz = _gi.itemsize
        _lst = sctypes['int']
        while (indx < len(_lst) and sz >= _lst[indx](0).itemsize):
            indx += 1
        sctypes['int'].insert(indx, _gi.type)
        sctypes['uint'].insert(indx, dtype('P').type) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:22,代碼來源:numerictypes.py

示例5: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def __init__(self, delimiter=None, comments=asbytes('#'), autostrip=True):
        self.comments = comments
        # Delimiter is a character
        if isinstance(delimiter, unicode):
            delimiter = delimiter.encode('ascii')
        if (delimiter is None) or _is_bytes_like(delimiter):
            delimiter = delimiter or None
            _handyman = self._delimited_splitter
        # Delimiter is a list of field widths
        elif hasattr(delimiter, '__iter__'):
            _handyman = self._variablewidth_splitter
            idx = np.cumsum([0] + list(delimiter))
            delimiter = [slice(i, j) for (i, j) in zip(idx[:-1], idx[1:])]
        # Delimiter is a single integer
        elif int(delimiter):
            (_handyman, delimiter) = (
                    self._fixedwidth_splitter, int(delimiter))
        else:
            (_handyman, delimiter) = (self._delimited_splitter, None)
        self.delimiter = delimiter
        if autostrip:
            self._handyman = self.autostrip(_handyman)
        else:
            self._handyman = _handyman
    # 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:27,代碼來源:_iotools.py

示例6: compute_primary_key_value_size

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def compute_primary_key_value_size(value):
        size = 1   # TAG_CELL_VALUE
        size += const.LITTLE_ENDIAN_SIZE + 1  # length + type

        if value in [INF_MIN, INF_MAX, PK_AUTO_INCR]:
            size += 1
            return size

        if isinstance(value, int):
            size += 8  #sizeof(int64_t)
        elif isinstance(value, six.text_type):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value.encode('utf-8'))
        elif isinstance(value, six.binary_type):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value)
        elif isinstance(value, bytearray):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value)
        else:
            raise OTSClientError("Unsupported primary key type:" + str(type(value)))
        return size 
開發者ID:aliyun,項目名稱:aliyun-tablestore-python-sdk,代碼行數:24,代碼來源:plain_buffer_builder.py

示例7: compute_column_value_size

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def compute_column_value_size(value):
        size = 1
        size += const.LITTLE_ENDIAN_SIZE + 1

        if isinstance(value, bool):
            size += 1
        elif isinstance(value, int):
            size += LITTLE_ENDIAN_64_SIZE
        elif isinstance(value, six.text_type):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value.encode('utf-8'))
        elif isinstance(value, six.binary_type):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value)
        elif isinstance(value, bytearray):
            size += const.LITTLE_ENDIAN_SIZE
            size += len(value)
        elif isinstance(value, float):
            size += LITTLE_ENDIAN_64_SIZE
        else:
            raise OTSClientError("Unsupported column type: " + str(type(value)))
        return size 
開發者ID:aliyun,項目名稱:aliyun-tablestore-python-sdk,代碼行數:24,代碼來源:plain_buffer_builder.py

示例8: write_column_value

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def write_column_value(self, value):
        if isinstance(value, bool):
            self.output_stream.write_raw_byte(VT_BOOLEAN)
            self.output_stream.write_boolean(value)
        elif isinstance(value, int):
            self.output_stream.write_raw_byte(VT_INTEGER)
            self.output_stream.write_raw_little_endian64(value)
        elif isinstance(value, six.text_type) or isinstance(value, six.binary_type):
            if isinstance(value, six.text_type):
                value = value.encode('utf-8')
            self.output_stream.write_raw_byte(VT_STRING)
            self.output_stream.write_raw_little_endian32(len(value))
            self.output_stream.write_bytes(value)
        elif isinstance(value, bytearray):
            self.output_stream.write_raw_byte(VT_BLOB)
            self.output_stream.write_raw_little_endian32(len(value))
            self.output_stream.write_bytes(value)
        elif isinstance(value, float):  
            self.output_stream.write_raw_byte(VT_DOUBLE)
            self.output_stream.write_double(value)
        else:
            raise OTSClientError("Unsupported column type: " + str(type(value))) 
開發者ID:aliyun,項目名稱:aliyun-tablestore-python-sdk,代碼行數:24,代碼來源:plain_buffer_coded_stream.py

示例9: __ReadCoils

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def __ReadCoils(self):
        try:
            modbusClient = ModbusClient(self.ipAddressEntry.get(), int(self.portEntry.get()))
            if (not modbusClient.is_connected()):
                modbusClient.connect()
            coils = modbusClient.read_coils(int(self.startingAddress.get()) - 1, int(self.quantity.get()))
            self.responseTextField.delete('1.0', END)
            for coil in coils:
                if (coil == FALSE):
                    response = "FALSE"
                else:
                    response = "TRUE"
                
                self.responseTextField.insert(END, response  + "\n")
        except Exception as e:
            messagebox.showerror('Exception Reading coils from Server', str(e))
        finally:
            modbusClient.close() 
開發者ID:rossmann-engineering,項目名稱:EasyModbusTCP.PY,代碼行數:20,代碼來源:easyModbusGUI.py

示例10: __ReadDiscreteInputs

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def __ReadDiscreteInputs(self):
        try:
            modbusClient = ModbusClient(self.ipAddressEntry.get(), int(self.portEntry.get()))
            if (not modbusClient.is_connected()):
                modbusClient.connect()
            discrInputs = modbusClient.read_discreteinputs(int(self.startingAddress.get()) - 1, int(self.quantity.get()))
            self.responseTextField.delete('1.0', END)
            for inp in discrInputs:
                if (inp == FALSE):
                    response = "FALSE"
                else:
                    response = "TRUE"
                
                self.responseTextField.insert(END, response  + "\n")
        except Exception as e:
            messagebox.showerror('Exception Reading discrete inputs from Server', str(e))
        finally:
            modbusClient.close() 
開發者ID:rossmann-engineering,項目名稱:EasyModbusTCP.PY,代碼行數:20,代碼來源:easyModbusGUI.py

示例11: __ReadHoldingRegisters

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def __ReadHoldingRegisters(self):
        try:
            modbusClient = ModbusClient(self.ipAddressEntry.get(), int(self.portEntry.get()))
            if (not modbusClient.is_connected()):
                modbusClient.connect()
            holdingRegisters = modbusClient.read_holdingregisters(int(self.startingAddress.get()) - 1, int(self.quantity.get()))
            self.responseTextField.delete('1.0', END)
            for register in holdingRegisters:
     
                
                self.responseTextField.insert(END, str(register)  + "\n")
        except Exception as e:
            messagebox.showerror('Exception Reading holding registers from Server', str(e))
        
        finally:
            modbusClient.close() 
開發者ID:rossmann-engineering,項目名稱:EasyModbusTCP.PY,代碼行數:18,代碼來源:easyModbusGUI.py

示例12: __init__

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def __init__(self, delimiter=None, comments=asbytes('#'), autostrip=True):
        self.comments = comments
        # Delimiter is a character
        if isinstance(delimiter, unicode):
            delimiter = delimiter.encode('ascii')
        if (delimiter is None) or _is_bytes_like(delimiter):
            delimiter = delimiter or None
            _handyman = self._delimited_splitter
        # Delimiter is a list of field widths
        elif hasattr(delimiter, '__iter__'):
            _handyman = self._variablewidth_splitter
            idx = np.cumsum([0] + list(delimiter))
            delimiter = [slice(i, j) for (i, j) in zip(idx[:-1], idx[1:])]
        # Delimiter is a single integer
        elif int(delimiter):
            (_handyman, delimiter) = (self._fixedwidth_splitter, int(delimiter))
        else:
            (_handyman, delimiter) = (self._delimited_splitter, None)
        self.delimiter = delimiter
        if autostrip:
            self._handyman = self.autostrip(_handyman)
        else:
            self._handyman = _handyman
    # 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:26,代碼來源:_iotools.py

示例13: mock_convert_coordinate

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def mock_convert_coordinate(chrom, pos):
    pos = int(chrom.replace('chr', ''))*int(1e9) + pos
    return(LIFT_MAP[pos]) 
開發者ID:macarthur-lab,項目名稱:seqr,代碼行數:5,代碼來源:lift_project_to_hg38_2_3_tests.py

示例14: handleSchema

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def handleSchema(self, schema, extra=None):
        """
        Return a jsonDict representation of an instance of an object
        defined by schema instantiated according to the rules defined by the
        subclass
        """
        switch = {
            'null': self.handleNull,
            'boolean': self.handleBoolean,
            'string': self.handleString,
            'bytes': self.handleBytes,
            'int': self.handleInt,
            'long': self.handleLong,
            'float': self.handleFloat,
            'double': self.handleDouble,
            'fixed': self.handleFixed,
            'enum': self.handleEnum,
            'array': self.handleArray,
            'map': self.handleMap,
            'union': self.handleUnion,
            'error_union': self.handleErrorUnion,
            'record': self.handleRecord,
            'error': self.handleError,
            'request': self.handleRequest,
        }
        handler = switch[schema.type]
        return self.handleSchemaDispatch(schema, handler, extra) 
開發者ID:genomicsengland,項目名稱:GelReportModels,代碼行數:29,代碼來源:avrotools.py

示例15: handleInt

# 需要導入模塊: import builtins [as 別名]
# 或者: from builtins import int [as 別名]
def handleInt(self, datum):
        if not ((isinstance(datum, int)) and
                INT_MIN_VALUE <= datum <= INT_MAX_VALUE):
            return datum
        else:
            return self.sinkValue 
開發者ID:genomicsengland,項目名稱:GelReportModels,代碼行數:8,代碼來源:avrotools.py


注:本文中的builtins.int方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。