首页 > 代码库 > map

map

def order():
sentence = "is2 Thi1s T4est 3a"
senList = str.split(sentence)
nums = list(range(1, 10))
nums = map(str, nums)
nums = list(nums)
position = []
for item in senList:
for i in nums:
if i in item:
position.append(i)
print(position)
position = list(map(int, position)) #将position里面的值转换成int
print(position)
for i in range(0, len(position)-1):
for j in range(i+1, len(position)):
if position[i] > position[j]:
tem = position[i]
position[i] = position[j]
position[j] = tem
tem = senList[i]
senList[i] = senList[j]
senList[j] = tem
print(‘ ‘.join(senList))


if __name__ == ‘__main__‘:
order()

map