当前位置: 首页 > 图灵资讯 > 行业资讯> python算术运算符的扩展功能

python算术运算符的扩展功能

发布时间:2024-06-18 09:41:28

1、加法运算符支持连接字符串的功能。

2、减法运算符支持取负操作。

3、乘法运算符支持添加列表的倍数与字符串n之间的连接。

4、除法运算符外,必须注意分母不能为0,否则会出现语法错误。

实例

test='ACM'
tests='ACMER'
final=test+tests#在这里,“+”将test和tests两个字符串连接起来
number=1000
newnumber=-number#在这里‘-’取number
index=[1,2,3,4]
index=index*3
print(final)#testtttest后的“+”连接+tests
print(newnumber)
print(index)#index添加“*”倍数后

以上是python算术运算符的扩展功能,希望对大家有所帮助。更多Python学习指导:python基础教程

本文教程操作环境:windows7系统Python 3.9.1,DELL G3电脑。

相关文章

python3兼容python2吗

python3兼容python2吗

2025-05-09
python3 whl怎么安装

python3 whl怎么安装

2025-05-09
python 字典怎么提取value

python 字典怎么提取value

2025-05-09
python 怎样计算字符串的长度

python 怎样计算字符串的长度

2025-05-09
python 怎么样反向输出字符串

python 怎么样反向输出字符串

2025-05-09
python 怎么判断字符串开头

python 怎么判断字符串开头

2025-05-09