zoukankan      html  css  js  c++  java
  • Python数据类型-布尔/数字/字符串/列表/元组/字典/集合

    代码

    bol     = True                  # 布尔
    num     = 100000000;            # 数字
    num2    = 0.0000001;            # 数字
    str     = "fangbei";            # 字符串
    str_cn  = u"你好,比特币";        # 字符串 中文unicode
    list    = [1, 2, 3, 3, 'fangbei'];                  # 列表,方括号,可重复,元素类型可不同
    tuple   = ('shenzhen', 'beijing', '0755', '0755');  # 元组,小括号,和列表相似,但内容不可修改!
    dict    = {'name': "fangbei", 'age': 28};           # 字典,大括号,存储键值对,类似json
    set     = set(['fang', 'bei', 'm']);                # 集合,用于去重
    
    print (type(bol));
    print (type(num));
    print (type(num2));
    print (type(str));
    print (type(str_cn));
    print (type(list));
    print (type(tuple));
    print (type(dict));
    print (type(set));

    返回

    <class 'bool'>
    <class 'int'>
    <class 'float'>
    <class 'str'>
    <class 'str'>
    <class 'list'>
    <class 'tuple'>
    <class 'dict'>
    <class 'set'>
  • 相关阅读:
    winfrom 获取当前系统时间
    netcore3.1API+efcore快速搭建
    php
    php
    php
    php-array的相关函数使用
    php-正则表达式
    vim的复制与粘贴
    vim的多窗口和文件切换操作
    laravel教程中出现500问题
  • 原文地址:https://www.cnblogs.com/bitquant/p/python-datatype.html
Copyright © 2011-2022 走看看