Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

生成文章()函数的修正以及字数统计的修正 #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gittig11
Copy link

1、生成文章()函数的修正
不需要用到for(let 空 in 主题){}循环
2、字数统计的修正
论述、后面垫话句末的空格要删掉,避免字数统计多了1。对应的要修改 增加段落(章节)函数。

@Dobby233Liu
Copy link

原版也有for(let 空 in 主题)

xx = input("请输入文章主题:")
for x in xx:

@gittig11
Copy link
Author

gittig11 commented Feb 11, 2020 via email

@Dobby233Liu
Copy link

Dobby233Liu commented Feb 11, 2020

原版是~6000字。可能js和py3处理字符串遍历的方式不一样。
edit:当时我是用a测试的,用学生会退会就出问题了。~32000字

@gittig11
Copy link
Author

我试了一下,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)

@Dobby233Liu
Copy link

这(for x in xx)也许是凑字的其中一种方法...

@gittig11
Copy link
Author

@Dobby233Liu 哈哈,这里可能是作者笔误吧,添加"for x in xx"后字数会多好几倍。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants