Open gittig11 opened 4 years ago
代码中设置了文章为6000字,但是生成的文章有好几万字?(原版没有测试,.html文件是这样的)------------------ 原始邮件 ------------------ 发件人: "Liu-Wen-Yuan"notifications@github.com 发送时间: 2020年2月11日(星期二) 下午2:58 收件人: "menzi11/BullshitGenerator"BullshitGenerator@noreply.github.com; 抄送: "gittig11"1710336112@qq.com;"Author"author@noreply.github.com; 主题: Re: [menzi11/BullshitGenerator] 生成文章()函数的修正以及字数统计的修正 (#172)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
原版是~6000字。可能js和py3处理字符串遍历的方式不一样。
edit:当时我是用a
测试的,用学生会退会
就出问题了。~32000字
我试了一下,Python版本的代码也有问题。 为什么要用“for x in xx”循环?当len(tmp) >= 6000时,tmp就是所需要的文本,print()打印出来。如果经过for in 循环,会多次打印,文本字数为 6000*len(主题)。 修改后的代码为:
if name == "main": xx = input("请输入文章主题:") tmp = str() while ( len(tmp) < 6000 ) : 分支 = random.randint(0,100) if 分支 < 5: tmp += 另起一段() elif 分支 < 20 : tmp += 来点名人名言() else: tmp += next(下一句废话) print(tmp)
这(for x in xx
)也许是凑字的其中一种方法...
@Dobby233Liu 哈哈,这里可能是作者笔误吧,添加"for x in xx"后字数会多好几倍。
1、生成文章()函数的修正 不需要用到for(let 空 in 主题){}循环 2、字数统计的修正 论述、后面垫话句末的空格要删掉,避免字数统计多了1。对应的要修改 增加段落(章节)函数。