我目前正在学习 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'
关于python - 针对特定字符的 Python 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38882432/