当前位置: 首页>>代码示例>>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;未经允许,请勿转载。