我已经遵循了使用geeksforgeeks中的faker的基本解释,并试图重现应用程序5:
import faker from Faker
fake = Faker()
# Print random sentences
print(fake.sentence())
# List has words that we want in our sentence
word_list = ["GFG", "Geeksforgeeks", "shaurya", "says", "Gfg", "GEEKS"]
# Let's print 5 sentences that have words from our word_list
for i in range(0, 5):
# You need to use ext_word_list = listnameyoucreated
print(fake.sentence(ext_word_list = word_list))
编译此代码时,会发生此错误:
回溯(最近通话最近一次):
文件“”,第13行,在 打印(假句子(ext_word_list = word_list))
TypeError:句子()得到了意外的关键字参数 'ext_word_list'
我发现尝试使函数为false时发生以下问题。word()使用我的预设字符串数组。我还仔细阅读了伪造的文档,即 faker.providers.lorem 部分,这些功能从此处起源,但无济于事。