使用Python的格式进行动词的变位

2024-09-30 06:32:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我在试着用python把这个动词写成英语

我的代码是:

verbFormat = ["I","you","he","she","we","they","yee",]
verbConjBePresent = [{0} + "am", {1} "are", {2} "is", {3} "is", {4} "are", {5} "are", {6} "are",]
print(verbConjBePresent.format(verbFormat))

我尝试过在vCBP中添加{x}+“str”,但没有添加。在

我试过用元组代替列表

编辑:我之所以要使用“verbFormat”列表,是因为我不需要每次更改动词时都重复这些单词(它应该涵盖大多数动词的大多数时态)

编辑2:为了将来搜索此主题的任何人的兴趣,我想添加代码,以便能够选择一个带有var[x]的共轭

^{pr2}$

Tags: 代码you编辑列表is动词amare
3条回答

字符串格式错误。您正在尝试格式化list。在

verbFormat = ["I","you","he","she","we","they","yee"]
verbConjBePresent = "{0} am;{1} are;{2} is;{3} is;{4} are;{5} are;{6} are"
print(verbConjBePresent.format(verbFormat).split(';'))

使用split(';')您将打印一个带有变化的列表。如果你想把所有的东西放在一个字符串中,只需去掉split。在

只需使用字符串并使用str.格式公司名称:

verbFormat = ["I","you","he","she","we","they","yee",]
verbConjBePresent = "{} am, {} are, {} is, {} is, {} are, {} are, {} are."
print(verbConjBePresent.format(*verbFormat))

这会给你:

^{pr2}$

str.格式对字符串而不是列表起作用。在

这是您想要作为输出的字符串吗?在

'I am, you are, he is, she is, we are, they are, yee are'

以下是制作代码:

^{pr2}$

相关问题 更多 >

    热门问题