本文介绍了如何使数字像Python中的字母形式一样出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:([one,4,three,7])会像:[1,4,3,7]



我的尝试:



def数字(lst):

digits = ['two', '七','三','五']

为'2735'中的c:

s = s.replace(c,digits(int(s)))

返回s

解决方案


for instance:(["one", 4, "three", 7]) would come out like:[1,4,3,7]

What I have tried:

def digits(lst):
digits=['two','seven','three','five']
for c in '2735':
s = s.replace(c, digits(int(s)))
return s

解决方案


这篇关于如何使数字像Python中的字母形式一样出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 21:49