python的题 求解

Python022

python的题 求解,第1张

def one(s):

return s == s[::-1]

def two(lst):

lst.sort()

del(lst[len(lst) - 1])

lst.append(lst.pop(0))

return lst.copy()

def three(s1, s2, s3):

return (s1 | s2 | s3,

s1 &s2 &s3,

(s1 | s2) - (s2 | s3))

def four(num):

return sum(map(int, str(num)))

def five():

text="12345"

fo = open("five.txt", "w", encoding="utf-8")

fo.write(text)

fo.close()

a=(0,0,0,0)

for i in range(4):

   for j in range(1,4):

       b = list(a)

       b[i]=j

       print(tuple(b))

元祖中的元素不可被修改,可以先将元祖转为list变更后再转回来