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

建议 chinese 返回一个对象, 以便用于数据处理 #7

Open
chen-kay opened this issue Feb 3, 2023 · 3 comments
Open

建议 chinese 返回一个对象, 以便用于数据处理 #7

chen-kay opened this issue Feb 3, 2023 · 3 comments

Comments

@chen-kay
Copy link

chen-kay commented Feb 3, 2023

from pydantic import BaseModel

class ZhModel(BaseModel):
    zh_year: str
    zh_month: str
    zh_day: str
    year_tiandi: str
    shengxiao: str

    def __str__(self):
        return f"{self.zh_year}{self.zh_month}{self.zh_day} {self.year_tiandi} ({self.shengxiao}年)"


class ZhDate1():
    def chinese(self):
        ......

        return ZhModel(
            zh_year=zh_year,
            zh_month=zh_month,
            zh_day=zh_day,
            year_tiandi=year_tiandi,
            shengxiao=shengxiao[(self.lunar_year - 1900) % 12],
        )
@EillesWan
Copy link
Contributor

好主意,妙啊

@CutePandaSh
Copy link
Owner

再增加一个返回类并没有意义,如果需要天干地支和生肖的单独数据,不如直接增加类里面的属性来提供。
chinese 方法的作用就是输出中文字符串的。

@zx-ui
Copy link

zx-ui commented Mar 4, 2024

新手直接用字符串分割获取chinese里面的年份,日期,生肖等信息。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants