目录

2638264600 的个人博客

记录精彩的程序人生

python基础知识

以python3为主

语法

在 Python 中,变量就是变量,它没有类型,我们所说的"类型"是变量所指的内存中对象的类型,Python 3 中有六个标准的数据类型:
Numbers(数字): int(整型)、float(浮点型)、bool(布尔型)、complex(复数)
·String(字符串)
·List(列表)
·Tuple(元组)
·Sets(集合)
·Dictionaries(字典)

a, b, c, d = 20, 5.5, True, 4+3j
print(type(a), type(b), type(c), type(d))
<class 'int'><class 'float'><class 'bool'><class 'complex'>

类型判断

isinstance(a,int) 看a是否为int,是返回true

  • type()不会认为子类是一种父类类型。
  • isinstance()会认为子类是一种父类类型。

代码风格

参考

代码:https://www.w3cschool.cn/python3/python3-data-type.html

风格:https://flask.github.net.cn/styleguide.html


标题:python基础知识
作者:2638264600
地址:http://bk.isseeker.com/articles/2024/05/15/1715742632250.html