#create a tuple
tuplex = tuple("index tuple")
print(tuplex)
#get index of the first item whose value is passed as parameter
index = tuplex.index("p")
print(index)
#define the index from which you want to search
index = tuplex.index("p", )
print(index)
#define the segment of the tuple to be searched
index = tuplex.index("e", , )
print(index)
#if item not exists in the tuple return ValueError Exception
index = tuplex.index("y")

python 元组查找元素返回索引的更多相关文章

  1. leetcode python两数之和返回索引

    给定一个整数数组和一个目标值,找出数组中和为目标值的两个数. 你可以假设每个输入只对应一种答案,且同样的元素不能被重复利用. 示例: 给定 nums = [2, 7, 11, 15], target ...

  2. Python 元组 min() 方法

    描述 Python 元组 min() 方法返回元组中元素最小值. 语法 min() 方法语法: min(T) 参数 T -- 指定的元组. 返回值 返回元组中元素最小值. 实例 以下实例展示了 min ...

  3. Python 元组 max() 方法

    描述 Python 元组 max() 方法返回元组中元素最大值. 语法 max() 方法语法: max(T) 参数 T -- 指定的元组. 返回值 返回元组中元素最大值. 实例 以下实例展示了 max ...

  4. Selenium(Python)等待元素出现

    1.显式等待 from selenium import webdriverfrom selenium.webdriver.common.by import Byfrom selenium.webdri ...

  5. 如何在python列表中查找某个元素的索引

    如何在python列表中查找某个元素的索引 2019-03-15 百度上回复别人的问题,几种方式的回答: 1) print('*'*15,'想找出里面有重复数据的索引值','*'*15) listA ...

  6. 使用Python学习selenium测试工具-4:查找元素

    转自:https://blog.csdn.net/wd168/article/details/51819930 web通常包含了Hyper Text Markup Language (HTML).Ca ...

  7. Python元组索引、截取

    Python元组索引.截取: 索引下标: tuple_1 = ('a','b','c','d','e','f','g','h') print(tuple_1[0]) # a print(tuple_1 ...

  8. python基础一 ------如何对元组各个元素进行命名

    对元组各个元素进行命名 1,通过对元组索引值的命名 2,通过标准库中的collections.nametuple替代内置touple 通过对元组索引值的命名 好比在c中的defined详细见代码 na ...

  9. python之enumerate函数:获取列表中每个元素的索引和值

    源码举例: def enumerate_fn(): ''' enumerate函数:获取每个元素的索引和值 :return:打印每个元素的索引和值 ''' list = ['] for index, ...

随机推荐

  1. [LeetCode] 225. Implement Stack using Queues_Easy tag: Design

    Implement the following operations of a stack using queues. push(x) -- Push element x onto stack. po ...

  2. thinkphp input

    变量修饰符 input函数支持对变量使用修饰符功能,可以更好的过滤变量. 用法如下: input('变量类型.变量名/修饰符'); 或者 Request::instance()->变量类型('变 ...

  3. Linux命令: 在线使用linux命令环境

    https://www.tutorialspoint.com/unix_terminal_online.php

  4. pythonl类继承例子

    #coding=utf-8 class Person(object):    def __init__(self,name,age):        self.name=name        sel ...

  5. mysql函数之四:concat() mysql 多个字段拼接

    语法: COUNT(DISTINCT expr ,[expr ...]) 函数使用说明:返回不同的非NULL 值数目.若找不到匹配的项,则COUNT(DISTINCT) 返回 0 Mysql的查询结果 ...

  6. WireShark 基本介绍

    文中内容主要转自:http://www.cnblogs.com/TankXiao/archive/2012/10/10/2711777.html 一.Wireshark 与 Fiddler 比较: F ...

  7. javascript中的console.log有什么作用?

    javascript中的console.log有什么作用? 主要是方便你调式javascript用的.你可以看到你在页面中输出的内容. 相比alert他的优点是:他能看到结构话的东西,如果是alert ...

  8. x86,x64,Any CPU区别

    https://blog.csdn.net/zuguangboy/article/details/51509670 1,即主程序(编译出来是exe文件的)是x86平台下编译的,而它所依赖的一个项目(或 ...

  9. 计算两个集合的差集——第六期 Power8 算法挑战赛

    第六期Power8大赛 1.1 比赛题目 题目: 计算两个集合的差集: 详细说明: 分别有集合A和B两个大数集合,求解集合A与B的差集(A中有,但B中无的元素),并将结果保存在集合C中,要求集合C中的 ...

  10. 使用 Vue.js 结合bootstrap 实现的分页控件

    原文链接:http://blog.csdn.net/qiuhaotc/article/details/53031884 源码下载: http://pan.baidu.com/s/1i4XgH6H 密码 ...