Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

python中数据类型

作者:爱我者我必爱*   发布日期:2025-03-13   浏览:53

# Python中的基本数据类型

# 1. 整数 (int)
# 整数是表示没有小数部分的数值。
a = 10
print(f"变量 a 的值为: {a}, 类型为: {type(a)}")

# 2. 浮点数 (float)
# 浮点数是带有小数部分的数值。
b = 3.14
print(f"变量 b 的值为: {b}, 类型为: {type(b)}")

# 3. 字符串 (str)
# 字符串是由字符组成的文本序列。
c = "Hello, World!"
print(f"变量 c 的值为: {c}, 类型为: {type(c)}")

# 4. 布尔值 (bool)
# 布尔值表示逻辑上的真或假。
d = True
print(f"变量 d 的值为: {d}, 类型为: {type(d)}")

# 5. 列表 (list)
# 列表是有序的可变集合,可以包含不同类型的元素。
e = [1, 2, 3, 'Python', 3.14]
print(f"变量 e 的值为: {e}, 类型为: {type(e)}")

# 6. 元组 (tuple)
# 元组是有序的不可变集合,一旦创建就不能修改。
f = (1, 2, 3, 'Python', 3.14)
print(f"变量 f 的值为: {f}, 类型为: {type(f)}")

# 7. 字典 (dict)
# 字典是无序的键值对集合,键必须是唯一的。
g = {'name': 'Alice', 'age': 25, 'city': 'Beijing'}
print(f"变量 g 的值为: {g}, 类型为: {type(g)}")

# 8. 集合 (set)
# 集合是无序且不重复的元素集合。
h = {1, 2, 3, 4, 5}
print(f"变量 h 的值为: {h}, 类型为: {type(h)}")

上一篇:python 定义

下一篇:pythonbreak用法

大家都在看

python时间格式

python ord和chr

python list.pop

python的for i in range

npm config set python

python代码简单

python读取文件夹

python中turtle

python 输出时间

python中list代表什么

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站