广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Python基本数据类型(四)
  • 254
分享到

Python基本数据类型(四)

数据类型Python 2023-01-31 00:01:03 254人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

5、双向队列(deque)函数说明一个线程安全的双向队列,可进可出,可以从两端添加和删除元素;class deque(object):     """     deque([iterable[, maxlen]]) --> deque

5、双向队列(deque)函数说明

一个线程安全的双向队列,可进可出,可以从两端添加和删除元素;

class deque(object):
    """
    deque([iterable[, maxlen]]) --> deque object
    
    Build an ordered collection with optimized access from its endpoints.
    
    提供了两端都可以操作的序列,这意味着,可以在序列前后都执行添加或删除;
    """
    def append(self, *args, **kwargs): # real signature unknown
        """ Add an element to the right side of the deque. """
        pass
        '''
        在deque的右边添加一个元素;
        例如:
        >>> from collections import deque
        >>> d = deque()
        >>> d
        deque([])
        >>> d.append('a')
        >>> d
        deque(['a'])
        >>> d.append('b')
        >>> d
        deque(['a', 'b'])
        >>> d.append(['b','c'])
        >>> d
        deque(['a', 'a', ['b', 'c']])
        >>> d.append('b','c')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: append() takes exactly one argument (2 given)
        '''
    def appendleft(self, *args, **kwargs): # real signature unknown
        """ Add an element to the left side of the deque. """
        pass
        '''
        在deque的左边添加一个元素;
        例如:
        >>> d = deque('a')
        >>> d
        deque(['a'])
        >>> d.appendleft('b')
        >>> d
        deque(['b', 'a'])
        '''
    def clear(self, *args, **kwargs): # real signature unknown
        """ Remove all elements from the deque. """
        pass
        '''
        从deque中删除所有元素;
        例如:
        >>> d = deque(['a','b'])
        >>> d
        deque(['a', 'b'])
        >>> d.clear()
        >>> d
        deque([])
        '''
    def count(self, value): # real signature unknown; restored from __doc__
        """ D.count(value) -> integer -- return number of occurrences of value """
        return 0
        '''
        返回值的出现次数;
        例如:
        >>> d = deque(['a','a'])
        >>> d.count('a')
        2
        '''
    def extend(self, *args, **kwargs): # real signature unknown
        """ Extend the right side of the deque with elements from the iterable """
        pass
        '''
        使用可迭代的元素扩展deque的右侧,即一次性可添加多个元素;
        例如:
        >>> d = deque(['a','b'])
        >>> d
        deque(['a', 'b'])        
        >>> d.extend(['c','d','e'])
        >>> d
        deque(['a', 'b', 'c', 'd', 'e'])
        '''
    def extendleft(self, *args, **kwargs): # real signature unknown
        """ Extend the left side of the deque with elements from the iterable """
        pass
        '''
        使用可迭代的元素扩展deque的左侧,即一次性可添加多个元素;
        例如:
        >>> d = deque(['a','b'])
        >>> d
        deque(['a', 'b'])
        >>> d.extendleft(['c','d','e'])
        >>> d
        deque(['e', 'd', 'c', 'a', 'b'])
        '''
    def pop(self, *args, **kwargs): # real signature unknown
        """ Remove and return the rightmost element. """
        pass
        '''
        删除并返回最右侧的元素;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.pop()
        'e'
        '''
    def popleft(self, *args, **kwargs): # real signature unknown
        """ Remove and return the leftmost element. """
        pass
        '''
        删除并返回最左侧的元素;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.popleft()
        'a'
        '''
    def remove(self, value): # real signature unknown; restored from __doc__
        """ D.remove(value) -- remove first occurrence of value. """
        pass
        '''
        删除指定的一个值;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.remove()
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: remove() takes exactly one argument (0 given)
        >>> d.remove('a')
        >>> d
        deque(['b', 'c', 'd', 'e'])
        >>> d.remove('c')
        >>> d
        deque(['b', 'd', 'e'])
        >>> d.remove('b','d')
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        TypeError: remove() takes exactly one argument (2 given)
        '''
    def reverse(self): # real signature unknown; restored from __doc__
        """ D.reverse() -- reverse *IN PLACE* """
        pass
        '''
        将元素反转;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.reverse()
        >>> d
        deque(['e', 'd', 'c', 'b', 'a'])
        '''
    def rotate(self, *args, **kwargs): # real signature unknown
        """ Rotate the deque n steps to the right (default n=1).  If n is negative, rotates left. """
        pass
        '''
        将最后的n个元素向右反转(默认n = 1),如果n为负,则将最前的n个元素向左反转;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.rotate()
        >>> d
        deque(['e', 'a', 'b', 'c', 'd'])
        >>> d.rotate(2)
        >>> d
        deque(['c', 'd', 'e', 'a', 'b'])
        >>> d.rotate(-4)
        >>> d
        deque(['b', 'c', 'd', 'e', 'a'])
        '''
    def __copy__(self, *args, **kwargs): # real signature unknown
        """ Return a shallow copy of a deque. """
        pass
        '''
        浅拷贝;
        '''
    def __delitem__(self, y): # real signature unknown; restored from __doc__
        """ x.__delitem__(y) <==> del x[y] """
        pass
        '''
        删除元素,等同于del;
        例如:
        >>> d = deque(['a','b','c','d','e'])
        >>> d.__delitem__(1)
        >>> d
        deque(['a', 'c', 'd', 'e'])
        >>> del d[2]
        >>> d
        deque(['a', 'c', 'e'])
        '''
    def __eq__(self, y): # real signature unknown; restored from __doc__
        """ x.__eq__(y) <==> x==y """
        pass
        '''
        等同于判断,返回布尔值;
        例如:
        >>> x = deque(['a','b','c','d','e'])
        >>> y = deque(['a','b','c','d'])
        >>> x.__eq__(y)
        False
        >>> x == y
        False
        >>> y = deque(['a','b','c','d','e'])
        >>> x == y
        True
        '''
    def __getattribute__(self, name): # real signature unknown; restored from __doc__
        """ x.__getattribute__('name') <==> x.name """
        pass
    def __getitem__(self, y): # real signature unknown; restored from __doc__
        """ x.__getitem__(y) <==> x[y] """
        pass
        '''
        返回队列指定下标的值,下标值需指定并为整数型,否则报错;
        例如:
        >>> x = deque(['a','b','c','d','e'])
        >>> x.__getitem__(2)
        'c'
        >>> x[3]
        'd'
        '''
    def __ge__(self, y): # real signature unknown; restored from __doc__
        """ x.__ge__(y) <==> x>=y """
        pass
        '''
        大于等于判断,返回布尔值;
        例如:
        >>> x = deque(['a','b','c','d','e'])
        >>> y = deque(['a','b','c','d'])
        >>> x.__ge__(y)
        True
        >>> x >= y
        True
        '''
    def __gt__(self, y): # real signature unknown; restored from __doc__
        """ x.__gt__(y) <==> x>y """
        pass
        '''
        大于判断,返回布尔值;
        '''
    def __iadd__(self, y): # real signature unknown; restored from __doc__
        """ x.__iadd__(y) <==> x+=y """
        pass
        '''
        自加,相当于+=;
        '''
    def __init__(self, iterable=(), maxlen=None): # known case of _collections.deque.__init__
        """
        deque([iterable[, maxlen]]) --> deque object
        
        Build an ordered collection with optimized access from its endpoints.
        # (copied from class doc)
        """
        pass
        '''
        构造方法,执行x = deque()时自动调用deque函数;
        '''
    def __iter__(self): # real signature unknown; restored from __doc__
        """ x.__iter__() <==> iter(x) """
        pass
        '''
        在deque上返回一个迭代器;
        '''
    def __len__(self): # real signature unknown; restored from __doc__
        """ x.__len__() <==> len(x) """
        pass
        '''
        返回队列长度;
        例如:
        >>> x = deque(['a','b','c','d','e'])
        >>> x.__len__()
        5
        >>> len(x)
        5
        '''
    def __le__(self, y): # real signature unknown; restored from __doc__
        """ x.__le__(y) <==> x<=y """
        pass
        '''
        小于等于判断,返回布尔值;
        '''
    def __lt__(self, y): # real signature unknown; restored from __doc__
        """ x.__lt__(y) <==> x<y """
        pass
        '''
        小于判断,返回布尔值;
        '''
    @staticmethod # known case of __new__
    def __new__(S, *more): # real signature unknown; restored from __doc__
        """ T.__new__(S, ...) -> a new object with type S, a subtype of T """
        pass
    def __ne__(self, y): # real signature unknown; restored from __doc__
        """ x.__ne__(y) <==> x!=y """
        pass
        '''
        不等于判断,返回布尔值;
        '''
    def __reduce__(self, *args, **kwargs): # real signature unknown
        """ Return state infORMation for pickling. """
        pass
        '''
        返回pickling的状态信息;
        '''
    def __repr__(self): # real signature unknown; restored from __doc__
        """ x.__repr__() <==> repr(x) """
        pass
        '''
        转化为解释器可读取的形式,即转换为字符串格式;
        '''
    def __reversed__(self): # real signature unknown; restored from __doc__
        """ D.__reversed__() -- return a reverse iterator over the deque """
        pass
        '''
        在deque上返回一个反向迭代器;
        '''
    def __setitem__(self, i, y): # real signature unknown; restored from __doc__
        """ x.__setitem__(i, y) <==> x[i]=y """
        pass
        '''
        对队列里,指定的下标值进行修改,i需为整数,并且不能超过队列的下标范围;
        例如:
        >>> x = deque(['a','b','c','d','e'])
        >>> x.__setitem__(2,'f')
        >>> x
        deque(['a', 'b', 'f', 'd', 'e'])
        >>> x[4] = 'g'
        >>> x
        deque(['a', 'b', 'f', 'd', 'g'])
        >>> x[5] = 'h'
        Traceback (most recent call last):
          File "<stdin>", line 1, in <module>
        IndexError: deque index out of range
        '''
    def __sizeof__(self): # real signature unknown; restored from __doc__
        """ D.__sizeof__() -- size of D in memory, in bytes """
        pass
        '''
        获取内存中队列的大小,以字节为单位;
        '''
    maxlen = property(lambda self: object(), lambda self, v: None, lambda self: None)  # default
    """maximum size of a deque or None if unbounded"""
    __hash__ = None

6、单向队列(Queue)函数说明

Queue是python标准库中的线程安全的队列FIFO(先进先出)实现,提供了一个适用于多线程编程的先进先出的数据结构,即队列,用来在生产者和消费者线程之间的信息传递;

class Queue:
    '''Create a queue object with a given maximum size.
    If maxsize is <= 0, the queue size is infinite.
    '''
    '''
    Queue提供了一个基本的FIFO容器,使用方法很简单,maxsize是个整数,指明了队列中能存放的数据个数的上限。一旦达到上限,插入会导致阻塞,直到队列中的数据被消费掉。如果maxsize小于或者等于0,队列大小没有限制。
    '''
    def __init__(self, maxsize=0):
        self.maxsize = maxsize
        self._init(maxsize)
        # mutex must be held whenever the queue is mutating.  All methods
        # that acquire mutex must release it before returning.  mutex
        # is shared between the three conditions, so acquiring and
        # releasing the conditions also acquires and releases mutex.
        self.mutex = threading.Lock()
        # Notify not_empty whenever an item is added to the queue; a
        # thread waiting to get is notified then.
        self.not_empty = threading.Condition(self.mutex)
        # Notify not_full whenever an item is removed from the queue;
        # a thread waiting to put is notified then.
        self.not_full = threading.Condition(self.mutex)
        # Notify all_tasks_done whenever the number of unfinished tasks
        # drops to zero; thread waiting to join() is notified to resume
        self.all_tasks_done = threading.Condition(self.mutex)
        self.unfinished_tasks = 0
        '''
        构造函数,执行x = queue()时自动调用Queue函数;
        '''
    def task_done(self):
        '''Indicate that a formerly enqueued task is complete.
        Used by Queue consumer threads.  For each get() used to fetch a task,
        a subsequent call to task_done() tells the queue that the processing
        on the task is complete.
        If a join() is currently blocking, it will resume when all items
        have been processed (meaning that a task_done() call was received
        for every item that had been put() into the queue).
        Raises a ValueError if called more times than there were items
        placed in the queue.
        '''
        with self.all_tasks_done:
            unfinished = self.unfinished_tasks - 1
            if unfinished <= 0:
                if unfinished < 0:
                    raise ValueError('task_done() called too many times')
                self.all_tasks_done.notify_all()
            self.unfinished_tasks = unfinished
        '''
        意味着之前入队的一个任务已经完成;
        由队列的消费者线程调用。每一个get()调用得到一个任务,接下来的task_done()调用告诉队列该任务已经处理完毕。
        如果当前一个join()正在阻塞,它将在队列中的所有任务都处理完时恢复执行(即每一个由put()调用入队的任务都有一个对应的task_done()调用)。
        如果调用的次数比在队列中放置的项目多,则引发ValueError;
        '''
    def join(self):
        '''Blocks until all items in the Queue have been Gotten and processed.
        The count of unfinished tasks goes up whenever an item is added to the
        queue. The count goes down whenever a consumer thread calls task_done()
        to indicate the item was retrieved and all work on it is complete.
        When the count of unfinished tasks drops to zero, join() unblocks.
        '''
        with self.all_tasks_done:
            while self.unfinished_tasks:
                self.all_tasks_done.wait()
        '''
        阻塞调用线程,直到队列中的所有任务被处理掉;
        只要有数据被加入队列,未完成的任务数就会增加;
        当消费者线程调用task_done()(意味着有消费者取得任务并完成任务),未完成的任务数就会减少;
        当未完成的任务数降到0,join()解除阻塞;
        '''
    def qsize(self):
        '''Return the approximate size of the queue (not reliable!).'''
        with self.mutex:
            return self._qsize()
        '''
        返回队列的大致大小(不可靠!)
        '''
    def empty(self):
        '''Return True if the queue is empty, False otherwise (not reliable!).
        This method is likely to be removed at some point.  Use qsize() == 0
        as a direct substitute, but be aware that either approach risks a race
        condition where a queue can grow before the result of empty() or
        qsize() can be used.
        To create code that needs to wait for all queued tasks to be
        completed, the preferred technique is to use the join() method.
        '''
        with self.mutex:
            return not self._qsize()
        '''
        如果队列为空,返回True,否则返回False(不可靠!);
        这种方法很可能在某个时候被删除。并由qsize() == 0来替代,但是要注意,不管是使用empty()还是qsize(),都有可能会在队列产生风险;
        要创建需要等待所有排队任务完成的代码,首选的技术是使用join()方法;
        '''
    def full(self):
        '''Return True if the queue is full, False otherwise (not reliable!).
        This method is likely to be removed at some point.  Use qsize() >= n
        as a direct substitute, but be aware that either approach risks a race
        condition where a queue can shrink before the result of full() or
        qsize() can be used.
        '''
        with self.mutex:
            return 0 < self.maxsize <= self._qsize()
        '''
        如果队列已满,返回True,否则返回False(不可靠!);
        这种方法很可能在某个时候被删除。并由qsize() >= n来替代,但是要注意,不管是使用full()还是qsize(),都有可能会在队列产生风险;
        '''
    def put(self, item, block=True, timeout=None):
        '''Put an item into the queue.
        If optional args 'block' is true and 'timeout' is None (the default),
        block if necessary until a free slot is available. If 'timeout' is
        a non-negative number, it blocks at most 'timeout' seconds and raises
        the Full exception if no free slot was available within that time.
        Otherwise ('block' is false), put an item on the queue if a free slot
        is immediately available, else raise the Full exception ('timeout'
        is ignored in that case).
        '''
        with self.not_full:
            if self.maxsize > 0:
                if not block:
                    if self._qsize() >= self.maxsize:
                        raise Full
                elif timeout is None:
                    while self._qsize() >= self.maxsize:
                        self.not_full.wait()
                elif timeout < 0:
                    raise ValueError("'timeout' must be a non-negative number")
                else:
                    endtime = time() + timeout
                    while self._qsize() >= self.maxsize:
                        remaining = endtime - time()
                        if remaining <= 0.0:
                            raise Full
                        self.not_full.wait(remaining)
            self._put(item)
            self.unfinished_tasks += 1
            self.not_empty.notify()
        '''
        将项目放入队列;
        如果可选的参数block为true,并且参数timeout为None(默认值)时,则表示队列需直到空闲时才可用;
        如果参数timeout为一个非负数,则表示它最多阻塞“超时”多少秒,并且如果在那个时间内队列没有空余槽,则引发Full异常;
        而当参数block为false时,则队列有空余槽时,就立即向项目放入队列中,否则引发Full异常(这种情况下,参数timeout不起作用)
        '''
    def get(self, block=True, timeout=None):
        '''Remove and return an item from the queue.
        If optional args 'block' is true and 'timeout' is None (the default),
        block if necessary until an item is available. If 'timeout' is
        a non-negative number, it blocks at most 'timeout' seconds and raises
        the Empty exception if no item was available within that time.
        Otherwise ('block' is false), return an item if one is immediately
        available, else raise the Empty exception ('timeout' is ignored
        in that case).
        '''
        with self.not_empty:
            if not block:
                if not self._qsize():
                    raise Empty
            elif timeout is None:
                while not self._qsize():
                    self.not_empty.wait()
            elif timeout < 0:
                raise ValueError("'timeout' must be a non-negative number")
            else:
                endtime = time() + timeout
                while not self._qsize():
                    remaining = endtime - time()
                    if remaining <= 0.0:
                        raise Empty
                    self.not_empty.wait(remaining)
            item = self._get()
            self.not_full.notify()
            return item
        '''
        从队列中删除并返回项目;
        如果可选的参数block为true,并且参数timeout为None(默认值)时,则表示队列需直到有项目时才可用;
        如果参数timeout为一个非负数,则表示它最多阻塞“超时”多少秒,并且如果在那个时间内没有可用的项目,则引发Empty异常;
        而当参数block为false时,则项目可用就立即返回结果,否则引发Empty异常(这种情况下,参数timeout不起作用)
        '''
    def put_nowait(self, item):
        '''Put an item into the queue without blocking.
        Only enqueue the item if a free slot is immediately available.
        Otherwise raise the Full exception.
        '''
        return self.put(item, block=False)
        '''
        没有阻塞时将项目放入队列;
        只有当队列有空余槽时,才将项目入列;
        否则引发Full异常;
        '''
    def get_nowait(self):
        '''Remove and return an item from the queue without blocking.
        Only get an item if one is immediately available. Otherwise
        raise the Empty exception.
        '''
        return self.get(block=False)
        '''
        没有阻塞时,从队列中删除并返回项目;
        只有当队列有可用项目时,才获取项目;
        否则引发Empty异常;
        '''
    # Override these methods to implement other queue organizations
    # (e.g. stack or priority queue).
    # These will only be called with appropriate locks held
    # Initialize the queue representation
    def _init(self, maxsize):
        self.queue = deque()
        '''
        初始化队列;
        '''
    def _qsize(self):
        return len(self.queue)
    # Put a new item in the queue
    def _put(self, item):
        self.queue.append(item)
        '''
        将新项目放入队列;
        '''
    # Get an item from the queue
    def _get(self):
        return self.queue.popleft()
        '''
        从队列中获取项目
        '''


--结束END--

本文标题: Python基本数据类型(四)

本文链接: https://www.lsjlt.com/news/182980.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • Python基本数据类型(四)
    5、双向队列(deque)函数说明一个线程安全的双向队列,可进可出,可以从两端添加和删除元素;class deque(object):     """     deque([iterable[, maxlen]]) --> deque...
    99+
    2023-01-31
    数据类型 Python
  • python基本数据类型(四)-集合与运
    1.集合 2.字典 3.运算符优先级 1.集合 创建:() set() 注意:创建空的集合要用set() 特点:元素唯一,无序 运算: &(交集) |(并集) -(差集) 方法: s.add(x) #添加单个元...
    99+
    2023-01-31
    数据类型 python
  • Python基本数据类型
    Numbers (数字) 1、数字数据类型用于存储数值。他们是不可改变的数据类型,这意味着改变数字数据类型会分配一个新的对象。 2、Python支持四种不同的数字类型: int(有符号整型) long(长整型[也可以代表八进制和十六进制...
    99+
    2023-01-31
    数据类型 Python
  • python3第四天(基本数据类型扩展)
    数字Number数字数据类型用于存储数值,数据类型是不允许改变的,因此要改变数字数据类型的值时,会被重新分配空间.因为变量是直接使用,所以可直接输入变量名.也可同时赋值.如,var1=10;删除变量用del 变量名1,变量名2...pyth...
    99+
    2023-01-31
    数据类型 第四天
  • Python--4 基本数据类型
      4.1 字符串   字符串str是在Python编写程序过程中,最常见的一种基本数据类型。字符串是许多单个子串组成的序列,其主要是用来表示文本。字符串是不可变数据类型,也就是说你要改变原字符串内的元素,只能是新建另一个字符串。   ...
    99+
    2023-01-30
    数据类型 Python
  • Python 基本数据类型 (二) -
      str.expandtabs([tabsize]): str类型的expandtabs函数,有一个可选参数tabsize(制表符大小)详细来说,expandtabs的意思就是,将字符串中的制表符\t,全部用空格来替换。至于用多少个空...
    99+
    2023-01-30
    数据类型 Python
  • Python基本数据类型(三)
    一、set的函数说明集合(set)是一个无序不重复元素的序列,基本功能是进行成员关系测试和删除重复元素,可以使用大括号({})或者 set()函数创建集合;注:创建一个空集合必须用set()而不是{ },因为{ }是用来创建一个空字典;在p...
    99+
    2023-01-31
    数据类型 Python
  • 学好python基本数据类型
    目录一、基本用法 1.注释 2.输出 3.变量 4.命名规范 5.变量的定义方式 二、python的数据类型 1.字符串类型 2.数字类型 3.List列表类型 4.tuple 元组...
    99+
    2022-11-12
  • python的基本数据类型(一)
    一.运算符逻辑运算and:两边都真则真or:有真则真not:非假是真顺序:()>==>not==>and>=or二.while.. elsewhile 条件: 代码块else: 当条件为假的时候执行三.主...
    99+
    2023-01-30
    数据类型 python
  • python基本数据类型(二)-pyth
    序列类型的自带方法 1.列表的常用方法 2.元祖的常用方法 3.字符串的常用方法 1.列表常用的方法 L.append(obj) #在列表末尾添加新的对象 L.clear() #清空列表 L.copy() ...
    99+
    2023-01-31
    数据类型 python pyth
  • python基本数据类型(一)-pyth
    1.python课程简介 2.数据类型 3.序列类型 1.python简介 1.python是一门编程语言,是一门完全面向对象的编程语言 2.如果对语言进行分类,那么python是一门强类型,动态的语言(若类型:比如int可以编程floa...
    99+
    2023-01-31
    数据类型 python pyth
  • Python基本数据类型__列表
    6、列表[list]在Python中列表用[]来表示,中间的元素可以是任何类型,用逗号分隔。列表是可变类型。列表的常用操作:在列表中我觉得比较重要的就属增删改查了,还有一些类似于字符串的操作;、定义列表:qq = [1,2,3,4,'12'...
    99+
    2023-01-31
    数据类型 列表 Python
  • 基本数据类型
    Python支持多种数据类型 在计算机内部,可把任何数据都看成一个对象,而变量就是在程序中用来指向这些数据对象的,对变量赋值就是把数据和变量给关联起来   整数   Python可以处理任意大小的整数,当然包括负整数,在程序中的表示方...
    99+
    2023-01-31
    数据类型
  • python基本数据类型练习题
    题目[1]:格式输出练习。在交互式状态下完成以下练习。 运行结果截图: 题目[2]:格式输出练习。在.py的文件中完成以下练习 代码: num = 100 print('%d ...
    99+
    2022-11-13
  • Python的基本数据类型之Number
    Python下载地址: https://www.python.org/downloads/ 部分参考资料:廖雪峰的网站 Python与Java在一定程度上比较相似,都是面向对象型的语言。首先搭配好Python的开发环境,网上相关...
    99+
    2023-01-31
    数据类型 Python Number
  • python基本数据类型的介绍
    int(整型)在32位机器上,整数的位数为32位,取值范围为-2**31~2**31-1,即-2147483648~2147483647在64位系统上,整数的位数为64位,取值范围为-2**63~2**63-1,即-922337203685...
    99+
    2023-01-31
    数据类型 python
  • Python全栈之基本数据类型
    目录1. number类型1.1 int整型1.2 float浮点型(小数)1.3 bool布尔型1.4 复数类型2. 字符串类型3. 列表_元组_字符串3.1 列表类型3.2 元组...
    99+
    2022-11-12
  • Python安装与基本数据类型
     人生苦短,我选Python。 Python比其他的语言来说真的简洁多了,很多时候想做的东西都有对应的模块可以导入,平时玩点小东西真心不错。 首先讲一下安装,其实没什么好讲的,点点点点点,完事。 这里的Add Python 3.7 to ...
    99+
    2023-01-31
    数据类型 Python
  • python基本数据类型之字典
    字典的定义与特性字典是Python语言中唯一的映射类型。定义:{key1:value1,key2:value2}1、键与值用冒号“:”分开; 2、项与项用逗号“,”分开;特性:1.key-value结构 2.key必须可hash、且必须为不...
    99+
    2023-01-31
    字典 数据类型 python
  • python变量和基本数据类型
    一、变量 1、声明变量: #!/usr/bin/env python# -*- coding: utf-8 -*- name = "tiger" 上述代码声明了一个变量,变量名为: name,变量name的值为:"tiger"变量的作用:其...
    99+
    2023-01-31
    变量 数据类型 python
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作