如何使数字像Python中的字母形式一样出现 [英] How do I make numbers come out in like the alphabetical form in Python
本文介绍了如何使数字像Python中的字母形式一样出现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的尝试:
def数字(lst):
digits = ['two', '七','三','五']
为'2735'中的c:
s = s.replace(c,digits(int(s)))
返回s
解决方案
有些搜索应该可以解决问题:
将文本编号转换为数字值 [ ^ ]
它在C#中,但应该很容易理解。
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
解决方案
Some searching should do the trick:
Converting Text Numbers to Numeric Values[^]
Its in C#, but should be easy to understand.
这篇关于如何使数字像Python中的字母形式一样出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文