字符串|test5

arr1 =[11,22,33]
arr2 =[44,22,33]
arrSame = []
arrOneHaveTwoHaveNot = []
arrOneHaveTwoHaveNot1 = []
#
获取内容相同的元素列表:
for item in arr1:
for iter in arr2:
if(item==iter):
arrSame.append(iter)
#获取arr1 和 arr2 中内容都不同的元素:
for item in arr1:
oneHas = 0
for iter in arr2:
if(item!=iter):
oneHas = 0
continue
else:
oneHas = 1
break
if(oneHas == 0):
print(item)
arrOneHaveTwoHaveNot.append(item)
i =3
for item in arr2:
oneHas = 0
for iter in arr1:
if(item!=iter):
oneHas = 0
continue#中断for循环
else:
oneHas = 1
break#跳出for循环

if(oneHas == 0):#判断是否为0 print(item) arrOneHaveTwoHaveNot1.append(item)

#打印两位数:
arr1="123456789"
arr2="123456789"
for item in arr1:
for item2 in arr2:
print(item+item2)
#乘法口诀表1~9:
for i in range(1,10):
for j in range(1,i+1):
n=j*i
print(j, "X", i, "=", n, " ",end="")#" "是1个空格
print("\n")#换行符
【字符串|test5】str1="bfsadaabbjhbfdvginhbbbihffhhhh"
#函数作用,在参数一的字符串中,寻找参数二的出现的次数
#第一个参数,字符串类型:被查找的字符串
#第二个参数,需要查找的字符
def strDisplayCount(strn,zifu):
baCuen=0
for item in strn:
if(item==zifu):
baCuen=baCuen+1
return baCuen

    推荐阅读