Skip to main content
 首页 » 编程设计

python之针对特定字符的 Python 列表

2025年05月04日10zhengyun_ustc

我目前正在学习 Python 中的列表,但我有一个我不太了解的具体案例。

L=['hello','pie'] 
L[0][1] 
'e' 

为什么 L[0][1] 输出为 'e'?我知道 L[0] = '你好'。所以我真的不明白 L[0][1] 如何 = 'e'。

请您参考如下方法:

因为您还可以在 Python 中索引字符串。

In [1]: L = ['hello', 'pie'] 
 
In [2]: L[0] 
Out[2]: 'hello' 
 
In [3]: 'hello'[1] 
Out[3]: 'e' 
 
In [4]: L[0][1] 
Out[4]: 'e'