### 制作母亲节词云图-祝福方式1

 `123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354` ``````import numpy import multidict import matplotlib.pyplot as plt from scipy.misc import imread from wordcloud import WordCloud, ImageColorGenerator def transform_format(val): """ 用于去除杂色 Arguments: val {[array]} -- RGB颜色组 Returns: [array] -- 去除杂色后的值 """ if val > 245 and val > 245 and val > 245: val = val = val = 255 return val else: return val def gen_happy_birthday_cloud(file, name): words = multidict.MultiDict() # 必须先初始化两个最大权重的 words.add('母亲节快乐', 10) words.add(name, 12) # 随意插入新的词语 for i in range(1000): words.add('妈妈', numpy.random.randint(1, 5)) words.add('您辛苦了', numpy.random.randint(1, 5)) words.add(name, numpy.random.randint(1, 5)) # 设定图片 bimg = imread(file) for color in range(len(bimg)): bimg[color] = list(map(transform_format, bimg[color])) wordcloud = WordCloud( background_color='white', mask=bimg, font_path='simhei.ttf' ).generate_from_frequencies(words) # 生成词云 bimgColors = ImageColorGenerator(bimg) # 渲染词云 plt.axis("off") plt.imshow(wordcloud.recolor(color_func=bimgColors)) plt.savefig(name + '.png') plt.show() gen_happy_birthday_cloud("mother.jpg", "母亲节快乐") ``````

### 飘落爱心玫瑰-祝福方式2

 `123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869` ``````import time from random import randint for i in range(1, 35): # 打印抬头 print('') heartStars = [2, 4, 8, 10, 14, 20, 26, 28, 40, 44, 52, 60, 64, 76] # *的位置 heartBreakLines = [13, 27, 41, 55, 69, 77] # 空格的位置 flowerBreakLines = [7, 15, 23, 31, 39, 46] # 玫瑰的空列位置 def addSpaces(a): # 添加空列 count = a while count > 0: print(' ', end='') count -= 1 def newLineWithSleep(): # 添加空行 time.sleep(0.3) print('\n', end='') play = 0 while play == 0: Left_Spaces = randint(8, 80) addSpaces(Left_Spaces) for i in range(0, 78): # 比心的形状 if i in heartBreakLines: newLineWithSleep() addSpaces(Left_Spaces) elif i in heartStars: print('*', end='') elif i in (32, 36): print('M', end='') elif i == 34: print('O', end='') else: print(' ', end='') newLineWithSleep() addSpaces(randint(8, 80)) print("H a p p y M o t h e r ' s D a y !", end='') newLineWithSleep() newLineWithSleep() Left_Spaces = randint(8, 80) addSpaces(Left_Spaces) for i in range(0, 47): # 向母亲献花 if i in flowerBreakLines: newLineWithSleep() addSpaces(Left_Spaces) elif i in (2, 8, 12, 18): print('{', end='') elif i in (3, 9, 13, 19): print('_', end='') elif i in (4, 10, 14, 20): print('}', end='') elif i in (27, 35, 43): print('|', end='') elif i in (34, 44): print('~', end='') elif i == 11: print('o', end='') else: print(' ', end='') print('\n', end='') ``````

### 写在最后
{"ft_lang_label":"__label__zh","ft_lang_prob":0.96003914,"math_prob":0.9468231,"size":566,"snap":"2021-31-2021-39","text_gpt3_token_len":604,"char_repetition_ratio":0.076512456,"word_repetition_ratio":0.0,"special_character_ratio":0.17667845,"punctuation_ratio":0.03076923,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9950724,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-09-22T23:32:22Z\",\"WARC-Record-ID\":\"<urn:uuid:a30044b5-12ed-4b3d-a5d9-3a0f249b540e>\",\"Content-Length\":\"54375\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3b49f45a-5520-485e-ae1b-1205671fc1ee>\",\"WARC-Concurrent-To\":\"<urn:uuid:c377c2ef-ccee-45c2-9c0a-4f5b02794966>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"http://www.justdopython.com/2020/05/09/mother_day/\",\"WARC-Payload-Digest\":\"sha1:OVGH2SHRN3H5EUYNQJEQDR7Q2VEHLVQG\",\"WARC-Block-Digest\":\"sha1:X5VHLWWE4ZPBH6YUSRSMOMBVZJGVKBXP\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-39/CC-MAIN-2021-39_segments_1631780057403.84_warc_CC-MAIN-20210922223752-20210923013752-00065.warc.gz\"}"}