一种排比句的生成

作者: 传习者戚 | 来源:发表于2017-09-29 14:54 被阅读19次

    ☺女人成功时,背后大多有一个不成功的男人。(●'◡'●)

    男人成功时,背后多半有一个伟大的女人。
    女人成功时,背后大多有一个不成功的男人。
    青年成功时,背后大多有一个很牛的长者。
    姑娘失败时,总会泪水满面,寻求安慰。
    男人失败时,总会闷头喝酒,谁也不用劝。
    女人失败时,总会眼泪汪汪,谁也劝不了。
    青年失败时,总会无所谓,继续飘游,爱谁谁。
    姑娘失败时,总会泪水满面,寻求安慰。
    男人恋爱时,一般会不懂也要装懂。
    女人恋爱时,一般会遇事懂也装作不懂。
    青年恋爱时,一般会摊事装没事,然后玩消失。
    姑娘恋爱时,一般会遮遮掩掩,欲罢难休。


    python3.5代码如下:

    
    # 人物基类
    class Person(object):
        type = '人'
        success = '成功状态'
    
        def success_reason(self):
            return self.__express("成功", self.success)
    
        failing = '失败状态'
    
        def failing_reason(self):
            return self.__express("失败", self.failing)
    
        loving = '恋爱状态'
    
        def loving_reason(self):
            return self.__express("恋爱", self.loving)
    
        def __express(self, type_name, sentence):
            return '%s%s时,%s' % (self.type, type_name, sentence)
    
    
    # 男人
    class Man(Person):
        type = '男人'
        success = '背后多半有一个伟大的女人。'
        failing = '总会闷头喝酒,谁也不用劝。'
        loving = '一般会不懂也要装懂。'
    
    
    # 女人
    class Woman(Person):
        type = '女人'
        success = '背后大多有一个不成功的男人。'
        failing = '总会眼泪汪汪,谁也劝不了。'
        loving = '一般会遇事懂也装作不懂。'
    
    
    # 青年
    class Youth(Person):
        type = '青年'
        success = '背后大多有一个很牛的长者。'
        failing = '总会无所谓,继续飘游,爱谁谁。'
        loving = '一般会摊事装没事,然后玩消失。'
    
    
    # 姑娘
    class Girl(Person):
        type = '姑娘'
        success = '背后大多有一个循循善诱的师者。'
        failing = '总会泪水满面,寻求安慰。'
        loving = '一般会遮遮掩掩,欲罢难休。'
    
    
    action = []
    action += [Man().success_reason()]
    action += [Woman().success_reason()]
    action += [Youth().success_reason()]
    action += [Girl().success_reason()]
    
    action += [Man().failing_reason()]
    action += [Woman().failing_reason()]
    action += [Youth().failing_reason()]
    action += [Girl().failing_reason()]
    
    action += [Man().loving_reason()]
    action += [Woman().loving_reason()]
    action += [Youth().loving_reason()]
    action += [Girl().loving_reason()]
    
    for a in action:
        print(a)
    
    

    相关文章

      网友评论

        本文标题:一种排比句的生成

        本文链接:https://www.haomeiwen.com/subject/gbyiextx.html