Python automatically generates articles

Source: Internet
Author: User

To cope with certain situations, 17 records are required. Although not very important, 17 copies are not very good. Roughly, this record is broadly divided into four segments. Then decided to provide four options per paragraph, each paragraph four selected one, pieced together into four paragraphs of text, saved into a file. The file name is called "XX record + Date". Contingency creation, using the "file operations" and "Generate random numbers" function. Relatively humble. Later extensions can be considered with a database.

#-*-coding:cp936-*-ImportRandom title='xxx Weekly meeting \ n Session time:'Timelist=['June 6','June 13','June 20','June 27','July 4','July 11','July 18','July 25',          'August 1','August 8','August 15','August 22','August 29',          'September 5','September 12','September 19','September 26',          ]#contains a list of 17 datesstr1='meeting place: xxx room \ n'str2='Moderator: Zhang San \ n'STR3='participants: AAA, BBB, ccc\n meeting content: \ n'List1=['first paragraph (type a) \ n','first paragraph (type B) \ n','first paragraph (type C) \ n','first paragraph (d type) \ n']list2=['second paragraph (type a) \ n','second paragraph (type B) \ n','second paragraph (type C) \ n','second paragraph (type D) \ n']list3=['third paragraph (type a) \ n','third paragraph (type B) \ n','third paragraph (type C) \ n','third paragraph (type D) \ n']list4=['Fourth paragraph (type a) \ n','Fourth paragraph (type B) \ n','Fourth paragraph (type C) \ n','Fourth paragraph (type D) \ n'] forIinchRange (0,17): AA=random.randint (0,3)#randomly assigned to AA "0, 1, 2,3" three valuesBb=random.randint (0,3) cc=random.randint (0,3) DD=random.randint (0,3)        PrintTimelist[i]PrintAa,bb,cc,dd F=open ('XXX Weekly Meeting'+timelist[i]+'. txt','W')#Create a new file with the filename "title + Date". R Read Only, W writable, a appendF.write (title + timelist[i] +'\ n'+ str1 + str2 + STR3 + LIST1[AA] + LIST2[BB] + LIST3[CC] + LIST4[DD] +'\ n')    #write the first paragraph, second paragraph, third paragraph, fourth paragraph in a randomly generated file. f.close ()#closes the file read and write. 

Python automatically generates articles

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.