chevron_left

Python 入门教程

免费
第 2.6 回

教程文档

Python 入门教程 - 公共方法

2023年11月13日
Python 入门教程

公共方法

运算符

运算符 Python 表达式 结果 描述 支持的数据类型
+ [1, 2] + [3, 4] [1, 2, 3, 4] 合并 字符串、列表、元组
* ['hello'] * 4 ['hello', 'hello', 'hello', 'hello'] 复制 字符串、列表、元组
in 3 in (1, 2, 3) True 元素是否存在 字符串、列表、元组、字典
not in 4 not in (1, 2, 3) True 元素不存在 字符串、列表、元组、字典

+

>>> "hello " + "clwy"
'hello clwy'
>>> [1, 2] + [3, 4]
[1, 2, 3, 4]
>>> ('a', 'b') + ('c', 'd')
('a', 'b', 'c', 'd')

*

>>> 'hi' * 4
'hihi...

课程介绍

此教程由长乐未央官方出品,目的是让新手能在最短的时间系统学会 Python

市面上现有的 Python 文字教程、书籍,或者视频教程,无不是啰嗦繁琐的要命。我们只想写一个简明,能快速上手的教程。期间也参考了大量现有资料,在前人基础上进一步修改,调整,简化代码,让人能一目了然。

适合这样的人

新手