我想创建一个函数,其中每个单词的每个单词

发布于 2025-02-06 05:55:48 字数 1398 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七分※倦醒 2025-02-13 05:55:48

将字典映射为您想要的符号

>>> m = {'a':'0','b':'00', 'c':'000'}

然后将其与用户的输入一起使用

>>> r = input('??')
??ab
>>> ''.join(m[c] for c in r)
'000'
>>> r = input('??')
??ac
>>> ''.join(m[c] for c in r)
'0000'
>>> r = input('??')
??abc
>>> ''.join(m[c] for c in r)
'000000'
>>>

Make a dictionary mapping characters to the symbol you want.

>>> m = {'a':'0','b':'00', 'c':'000'}

Then use it along with a user's input

>>> r = input('??')
??ab
>>> ''.join(m[c] for c in r)
'000'
>>> r = input('??')
??ac
>>> ''.join(m[c] for c in r)
'0000'
>>> r = input('??')
??abc
>>> ''.join(m[c] for c in r)
'000000'
>>>
安静被遗忘 2025-02-13 05:55:48

这是一个简单的程序,可以执行您的要求:

def codifier():  
    userImp = input(str("write a word: "))   
    for char in userImp:
        print(end="0" * (ord(char) - ord('a') + 1))

codifier()  

Here is a simple program that does what you are asking for:

def codifier():  
    userImp = input(str("write a word: "))   
    for char in userImp:
        print(end="0" * (ord(char) - ord('a') + 1))

codifier()  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文