如何从列表中选择一个随机的英语单词 [英] How to pick a random english word from a list

查看:129
本文介绍了如何从列表中选择一个随机的英语单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得返回随机英语单词(最好是名词)的函数而又不事先保存文件中所有可能单词的列表的最佳方法是什么?

What would be the best way to go about getting a function that returns a random English word (preferably a noun), without keeping a list of all possible words in a file before hand?

推荐答案

单词列表不需要占用那么多空间.

Word lists need not take up all that much space.

这是一个 JSON单词列表,包含5000多个单词,所有名词.它的时钟频率不到50K,这是中型jpeg图像的大小.

Here's a JSON wordlist with over 5000 words, all nouns. It clocks in at under 50K, the size of a medium-sized jpeg image.

我会选择一个随机的练习作为读者的练习.

I'll leave choosing a random one as an exercise for the reader.

这篇关于如何从列表中选择一个随机的英语单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆