社区
脚本语言
帖子详情
关于Python中dictionary中关键字问题
yjgx007
2008-04-02 11:26:52
为什么list不能作为关键字,tuple可以呢?
这里涉及到immutable概念, 只有不可变的对象能够成为关键字,list是可变的.
...全文
70
1
打赏
收藏
关于Python中dictionary中关键字问题
为什么list不能作为关键字,tuple可以呢? 这里涉及到immutable概念, 只有不可变的对象能够成为关键字,list是可变的.
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
1 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ChumpKlutz
2008-04-02
打赏
举报
回复
list是可变对象所以不成作为key
python
自动化RobotFramework
中
Collections字典
关键字
使用(五).docx
RobotFramework框架是一个很通用的自动化测试框架,支持常用的http接口自动化、selenium等UI自动化 容易上手,很适合新人学习和了解,有需要的可以下载学习
RobotFramework常用
关键字
(1).pdf
RobotFramework常⽤
关键字
常⽤
关键字
虽然通过RIDE提供"填表"⼀样的写测试⽤例的⽅式。但它却⽀持强⼤的
关键字
功能,以及可以开发
关键字
的扩展能⼒。 Comment 注释功能,也可以使⽤
python
中
的"#" Comment 注释 注释 #注释 log 打印。类似于print log Hello World set variable 定义变量 ${a} set variable Hello World!!! log ${a} catenate 连接对象 ${a} catenate hello world log ${a} SEPARATOR 对多个连接进⾏分割(必须⼤写) ${a} catenate SEPARATOR=, hello world log ${a} create list 创建列表 ${a} create list a b c log ${a} 通过 通过@{}定义列表 定义列表 必须使⽤ log many 打印 @{a} create list a b c log many @{a} get time 获取当前时间 ${a} get time log ${a} sleep 设置休眠时间 ${a} get time sleep 5 ${a} get time ${a} get time run keyword if 通过该语句可以编写if分⽀语句 ${a} set variable 59 run keyword if ${a}>=90 log 优秀 ... ELSE IF a >= 60and{a}<90 log ⼀般 ... ELSE log 菜 :FOR 实现循环 :FOR ${i} IN RANGE 10 log ${i} 列表遍历 列表遍历 @{lista} create list a b c :FOR ${a} in @{lista} log ${a} Exit For Loop If 退出循环的判断语句 @{lista} create list a b c :FOR ${a} IN @{lista} exit for loop if '${a}'=='b' log ${a} Evaluate 执⾏
python
中
的⽅法 ${a} Evaluate random.randint(1000,9999) random log ${a} Import Library 导⼊标准和第三⽅模块或框架。⽐如调⽤unittest单元测试框架 Import Library unittest 导⼊外部py⽂件 Import Library c:/test.py ${sum} add 3 4 log ${sum} Import Library c:/test.py ${a} Evaluate int(4) ${b} Evaluate int(5) ${sum} add ${a} ${b} log ${sum} Take Screenshot 截取当前屏幕,Screenshot库为robot framework的标准类库,需⼿动加载 字典 字典 Collections库:该库为Robot Framework标准类库,它提供的
关键字
主要⽤于列表、索引、字典的处理。需要⼿动加载。 Create
Dictionary
创建字典 ${dict} Create
Dictionary
sname Luffy age 19 Get
Dictionary
Items 获取字典
中
的key和value " item"Get
Dictionary
Items"{dict} " " log " ${item} "" Get
Dictionary
Keys 获取字典
中
的key ${keys} Get
Dictionary
keys ${dict} log ${keys} Get
Dictionary
Values 获取字典
中
的value ${values} Get
Dictionary
Values ${dict} log ${values} Get From
Dictionary
根据key获取对应的value ${a} Get From
Dictionary
${dict} sname log ${a} Processing math: 100%
7--字典与集合.pdf
Python
python
自动化测试框架RobotFramework内置库BuiltIn介绍(二)
RobotFramework框架是一个很通用的自动化测试框架,支持常用的http接口自动化、selenium等UI自动化 容易上手,很适合新人学习和了解,有需要的可以下载学习
python
中
前缀运算符 *和 **的用法示例详解
这篇主要探讨 ** 和 * 前缀运算符,**在变量之前使用的*and **运算符. 一个星(*):表示接收的参数作为元组来处理 两个星(**):表示接收的参数作为字典来处理 简单示例: >>> numbers = [2, 1, 3, 4, 7] >>> more_numbers = [*numbers, 11, 18] >>> print(*more_numbers, sep=', ') 2, 1, 3, 4, 7, 11, 18 用途: 使用 * 和 ** 将参数传递给函数 使用**和**捕获传递给函数的参数 使用*只接受
关键字
参数 使用*元组拆包过程
中
捕获项目 使
脚本语言
37,743
社区成员
34,212
社区内容
发帖
与我相关
我的任务
脚本语言
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
复制链接
扫一扫
分享
社区描述
JavaScript,VBScript,AngleScript,ActionScript,Shell,Perl,Ruby,Lua,Tcl,Scala,MaxScript 等脚本语言交流。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
试试用AI创作助手写篇文章吧
+ 用AI写文章