在Python中,可以使用`list.index()`方法来查询一个值在列表中的下标(索引)。以下是一个示例代码,展示如何使用这个方法:
```python
定义一个列表
my_list = ['apple', 'banana', 'cherry', 'date']
查询值'cherry'在列表中的下标
index_of_cherry = my_list.index('cherry')
打印下标
print("The index of 'cherry' is:", index_of_cherry)
```
这段代码会输出:
```
The index of 'cherry' is: 2
```
请注意,`list.index()`方法会返回列表中第一个匹配元素的索引。如果列表中有多个相同的值,它只会返回第一个匹配项的索引。如果指定的值不在列表中,会抛出一个`ValueError`异常。