日期和时间对象可以根据它们是否包含时区信息而分为“感知型”和“简单型”两类。
充分掌握应用性算法和政治性时间调整信息例如时区和夏令时的情况下,一个 感知型 对象就能相对于其他感知型对象来精确定位自身时间点。 感知型对象是用来表示一个没有解释空间的固定时间点。
简单型 对象没有包含足够多的信息来无歧义地相对于其他 date/time 对象来定位自身时间点。 不论一个简单型对象所代表的是世界标准时间(UTC)、当地时间还是某个其他时区的时间完全取决于具体程序,就像一个特定数字所代表的是米、英里还是质量完全取决于具体程序一样。 简单型对象更易于理解和使用,代价则是忽略了某些现实性考量。
import turtle,datetime
def drawLine(draw):
turtle.pendown() if draw else turtle.penup()
turtle.fd(40)
turtle.right(90)
turtle.pencolor("gold")
def drawDight(d):
drawLine(True) if d in [2,3,4,5,6,8,9] else drawLine(False)
drawLine(True) if d in [0,1,3, 4, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if d in [0,2, 3, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0,2, 6, 8] else drawLine(False)
turtle.left(90)
drawLine(True) if d in [0,4, 5, 6, 8, 9] else drawLine(False)
drawLine(True) if d in [0,2, 3, 5, 6, 7, 8, 9] else drawLine(False)
drawLine(True) if d in [0,1,2, 3, 4, 7, 8, 9] else drawLine(False)
turtle.left(180)
turtle.penup()
turtle.fd(20)
def drawDate(date):
for i in date:
drawDight(eval(i))
def main():
turtle.setup(800,350,200,200)
turtle.penup()
turtle.fd(-300)
turtle.pensize(5)
turtle.pencolor("gold")
drawDate(datetime.datetime.now().strftime('%Y%m%d'))
turtle.hideturtle()
turtle.done()
main()
运行结果如下: