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

减少连续重复;支持命令行传参设置主题、文章长度 #48

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions 自动狗屁不通文章生成器.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import os, re
import os, re, sys
import random,readJSON

data = readJSON.读JSON文件("data.json")
Expand All @@ -20,7 +20,8 @@ def 洗牌遍历(列表):
while True:
random.shuffle(池)
for 元素 in 池:
yield 元素
if not tmp.endswith(元素):
yield 元素

下一句废话 = 洗牌遍历(废话)
下一句名人名言 = 洗牌遍历(名人名言)
Expand All @@ -39,10 +40,15 @@ def 另起一段():
return xx

if __name__ == "__main__":
xx = input("请输入文章主题:")
try:
xx = sys.argv[1]
文章长度 = int(sys.argv[2])
except:
xx = input("请输入文章主题:")
文章长度 = 6000
for x in xx:
tmp = str()
while ( len(tmp) < 6000 ) :
while ( len(tmp) < 文章长度 ) :
分支 = random.randint(0,100)
if 分支 < 5:
tmp += 另起一段()
Expand All @@ -51,4 +57,4 @@ def 另起一段():
else:
tmp += next(下一句废话)
tmp = tmp.replace("x",xx)
print(tmp)
print(tmp)