1 Star 0 Fork 0

北京大学-夏敏/Python_XDRupdate

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
随机生成句子的python代码2.txt 832 Bytes
一键复制 编辑 原始数据 按行查看 历史
XDR 提交于 2020-11-13 12:41 . 随机生成句子的代码2
import random
import sys
articles = ["一个", "一只"]
subjects = ["小猫", "小狗", "小马", "小孩"]
verbs = ["唱歌", "跳舞", "奔跑", "思考", "倾听", "划船"]
adverbs = ["轻轻地", "快乐地", "安静地", "悲伤地"]
lines = 50
if len(sys.argv) > 1:
try:
temp = int(sys.argv[1])
if 1 <= temp <= 10:
lines = temp
else:
print("lines must be 1-10 inclusive")
except ValueError:
print("usage: badpoetry.py [lines]")
while lines:
article = random.choice(articles)
subject = random.choice(subjects)
verb = random.choice(verbs)
if random.randint(0, 1) == 0:
print(article, subject, verb)
else:
adverb = random.choice(adverbs)
print(article,subject,verb,adverb)
lines -= 1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/pkuecho/python_-xdr.git
git@gitee.com:pkuecho/python_-xdr.git
pkuecho
python_-xdr
Python_XDRupdate
master

搜索帮助