Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to write an online generator of Tibetan poems

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces how to use Python to compile an online generator of Tibetan poems, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe that after reading this article on how to use Python to write an online generator of Tibetan poems, you will have something to gain, let's take a look.

First, Tibetan head poem ("Little Romance")

We have to go to work again. Let's complain-- think that the next national legal holiday will have to wait until New Year's Day.

It's very sad, it's so long! Are you sad, too? it doesn't matter. Let's just have some fun. I saw a funny thing these days.

Nagging with you, that is to say, there is a very "romantic" boy, * * sent his girlfriend a hidden poem, * * can be said to be very attentive, you feel it.

Give me some positive teaching materials--

I heard that Yoshiro's jelly orange tastes better. If you listen to more joyful words, you will be really happy. You won't find that this is my Tibetan head poem.

I slept in the uninhabited wilderness at dusk and saw the Ravens sitting on the withered vines and the magpies were here to forget to return to the cheerful songs resounding through the wilderness you are coming to me

Normal Tibetan head poetry--

Mini Program, which we teach you to write in Python today, is made up of different verses. It's easier to write this way. .

For example: go on a date after work

Look down at Yang Fu Road Dust author: Zheng Gu

Xunban Chaochuan shed tears. Author: Guan Xiu

Who does pine mash get drunk with? author: Li Shangyin

The wind blows and the sound of cranes rises. Author: Liu Cang.

Huizhen Guang Temple about the Palace Wall author: Madame Hua Rui

Who will get the author in so many states: du Xunhe

Then how can I finish this Mini Program? Let's officially knock on the code.

Second, implementation code

This Mini Program is very simple ha: here is to crawl a lot of verses and put them in the txt text!

The code is as follows:

File=open (r "C:\ Users\ admin\ Desktop\ video clip\ basic video\ game code\ utility gadget collection 06\ practical 09. Poetry\ Tibetan head poem\ dataset_final.txt ", 'ringing training encodingpoem writing utfMei8') file.readline () dict1= {} dict2= {} result= (file.readlines ()) for line in file.readlines (): line = line.strip () shiju,shiming Shiren = line.split ('\ t') if shiju not in dict1: dict1 [shiju] = shiming if shiju not in dict2: dict2 [shiju] = shiren#print (dict2) for shiju1 in dict2: result [shiju1] = "+'\ tpoem +" author: "+ dict2 [shiju1] print (result) str_list=input (" Please enter the field you want to generate Tibetan head poem: ") for i in range (len (str_list)): for key Value in result.items (): if len (str_list) > len (key): continue if len (str_list) > 7: break if str_ list [I] = = key [I]: print (key,value) break 3. Effect display

For example: I like you?

For example: I miss you very much

This is the end of the article on "how to write an online generator of Tibetan poems with Python". Thank you for reading! I believe that everyone has a certain understanding of "how to use Python to write an online generator of Tibetan poems". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report