首页 > 代码库 > 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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。