一:利用年份公式推算12生肖,以及用if-else编写12星座和24节气。
1、PyQt设计界面:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/7535533d554c995959f7c94973f4f969.png)
2、对象命名:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/1edca46d4a54373d05733b139d621041.png)
3、源程序:
在这里插入代码片
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from Ui_MainWindow import Ui_MainWindow
class CMainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent = None):
super(CMainWindow, self).__init__(parent)
self.setupUi(self)
self.show()
def Sure(self):
nian = int(self.txtNumber1.text())
yue = self.txtNumber2.text()
ri = self.txtNumber3.text()
Months = self.txtNumber4.text()
Day = self.txtNumber5.text()
l = nian%12+1
if l == 5:
strOutnian =str(nian) + "年" + str(yue) + "月" + str(ri) + "日,今年是鼠年。"
if l == 6:
strOutnian =str(nian) + "年" + str(yue) + "月" + str(ri) + "日,今年是牛年。"
if l == 7:
strOutnian =str(nian) + "年" + str(yue) + "月" + str(ri) + "日,今年是虎年。"
if l == 8:
strOutnian =str(nian) + "年" + str(yue) +