2019-04-04
阅读量:
594
序列相加
可使用加法运算符来拼接序列。
[1,2,3]+[4,5,6] # [1,2,3,4,5,6]
'Hello,'+ 'world!' # 'Hello,world!'
[1,2,3]+'world!' # TypeError: can only concatenate list (not "str") to list
从错误消息可知,不能拼接列表和字符串,虽然它们都是序列。一般而言,不能拼接不同类型的序列。






评论(0)


暂无数据
推荐帖子
0条评论
0条评论
0条评论