Python 函数传入多个参数


Python 函数传入多个参数直接在传参处填写 *形参就行了如下,我们写一个计算乘法的函数def multiply(*numbers): total = 1 for i in numbers: total *= i return totalprint(multiply

Python内置函数的使用


Python内置函数的使用# Python内置函数print(round(2.5)) # 取整数print(abs(-2.5)) # 取绝对值name = ' meowrain'print(name.upper()) # 全部大写print(name.lower()) # 全

Python格式化字符串常量f-string


Python格式化字符串常量f-string直接举例子吧:我们想打印出meowrain is 18 years old可以这么写name = 'meowrain 'age = 18print(name + 'is ' + str(age) + ' years

Python转义字符\


Python转义字符如果像下面这样写的话,会直接被IDE红线报错course = "python "programming""print(course)那么我想打印出python "programming"这样的字符串怎么办呢?这就要用到转

python-字符串常见操作


查找内容len用于获取字符串长度例子:myName = "Lihua "print(len(myName))上面这串代码执行的结果是6为什么是6呢,Lihua明明是5个字符啊,这就错了,观察可以看到,我在Lihua后面还加了一个空格,len()函数是把空格也计算到字符串长度里面的

python 字符串切片


字符串索引机制0~len()-1-len() ~ -1上面是两种索引机制