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 中內容都不一樣的元素:app

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 =3ide

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)code

#乘法口訣表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")#換行符it

str1="bfsadaabbjhbfdvginhbbbihffhhhh"
#函數做用,在參數一的字符串中,尋找參數二的出現的次數
#第一個參數,字符串類型:被查找的字符串
#第二個參數,須要查找的字符
def strDisplayCount(strn,zifu):
baCuen=0
for item in strn:
if(item==zifu):
baCuen=baCuen+1for循環

return baCuen
相關文章
相關標籤/搜索