代码拉取完成,页面将自动刷新
from random import choice, seed, randrange
articles = ("a", "the","1","2","3","4","5","6","7","8","9","10")
nouns = ("cat", "dog", "sheep", "rabbit", "tiger", "chicken",
"fish", "grass", "seed", "carrot", "apple")
verbs = ("eats", "catches", "finds")
def sentence():
return noun_phrase() + verb_phrase()
def noun_phrase():
return [choice(articles), choice(nouns)]
def verb_phrase():
vp = [choice(verbs)]
if randrange(3) > 0:
vp.extend(noun_phrase())
return vp
def creat():
with open('data.txt','w')as txt:
seed()
for i in range(10000000):
txt.write(" ".join(sentence()))
txt.write('\n')
if __name__ == "__main__":
creat()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。