Python 3中提供了许多内置的数据结构,可以用于存储和操作数据。下面是一些常见的Python 3数据结构示例:
1. 列表(List):有序、可变的数据集合,可以包含不同类型的元素。
```python
my_list = [1, 2, 3, 'a', 'b', 'c']
print(my_list)
```
2. 元组(Tuple):有序、不可变的数据集合,可以包含不同类型的元素。
```python
my_tuple = (1, 2, 3, 'a', 'b', 'c')
print(my_tuple)
```
3. 集合(Set):无序、不重复的数据集合。
```python
my_set = {1, 2, 3, 'a', 'b', 'c'}
print(my_set)
```
4. 字典(Dictionary):无序的键值对集合,可以通过键访问值。
```python
my_dict = {'name': 'John', 'age': 30, 'city': 'New York'}
print(my_dict)
```
5. 字符串(String):有序的字符集合&#x