我正在尝试用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]
的共轭verbFormat = ["I","you","he","she","we","they","yee",]
verbConjBePresent = "{} am; {} are; {} is; {} is; {} are; {} are; {} are"
verbBePresent =(verbConjBePresent.format(*verbFormat).split(';'))
print(verbBePresent[0])
答案 0 :(得分:0)
只需使用字符串并使用str.format解压缩列表:
verbFormat = ["I","you","he","she","we","they","yee",]
verbConjBePresent = "{} am, {} are, {} is, {} is, {} are, {} are, {} are."
print(verbConjBePresent.format(*verbFormat))
哪个会给你:
I am, you are, he is, she is, we are, they are, yee are.
str.format 适用于字符串而不是列表。
答案 1 :(得分:0)
这是你想要输出的字符串吗?
'I am, you are, he is, she is, we are, they are, yee are'
以下是制作它的代码:
verbConjBePresent = '{0} am, {1} are, {2} is, {3} is, {4} are, {5} are, {6} are'
print(verbConjBePresent.format(*verbFormat))
答案 2 :(得分:0)
您的字符串格式错误。您正在尝试格式化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(';')
使用<?php
$id= $_GET['ud_id'];
$first= $_GET['ud_first'];
$last= $_GET['ud_last'];
require_once ('mysqli_connect.php'); //connection to the database
$sql = "UPDATE contacts SET FirstName ='$first', LastName='$last' WHERE id='$id'";
$result = mysqli_query($dbc,$sql);
mysqli_close($dbc);
?>
,您将打印带有变形的列表。如果你想在一个字符串中一起使用,只需删除split。