首页 > 编程语言 > 详细

python 运算符和字符串

时间:2020-03-31 01:27:28      阅读:98      评论:0      收藏:0      [点我收藏+]

1、加减乘除

2、% —— 取余

3、// —— 取商

  ** —— 幂

4、判断某个东西是否在某个东西里面包含 in  not in

5、数字、字符串、布尔值(true、false)

 

6、6个字符串的魔法

join

#每个字符串中插入字符
# test = ‘功夫不负有心人‘
# #t = ‘ ‘
# v = ‘ ‘.join(test)
# print(v)

 

split

#分割字符串

#分割字符串,后面不跟参数全部分割
test = ‘asdfkjhsdfssf‘
v = test.split(s,1)
print(v)

 

find

test = alex
v = test.find(e)
print(v)

 

 

strip

#去除空白
test =   alex
v = test.strip()
print(v)

 

upper

lower

#判断是否全为小写,upper为转换小写
test = Alex
v1 = test.islower()
v2 = test.upper()
print(v1,v2)

 

python 运算符和字符串

原文:https://www.cnblogs.com/BruceKim/p/12571746.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!