python生成12点的时钟_绘制一个使用python打印当前时间的时钟

1586010002-jmsa.png

i am supposed to draw a clock in python without using any modules that need downloading like turtle module, rather id have to use the stddraw module. The clock would also have to give the current time in hours, minutes, and seconds represented on the clock. I am struggling to understand how i'm supposed to go about doing this since i havent done any drawing or anything before so this is really new territory in terms of programming. Any ideas on how to go about doing this or advice is greatly appreciated!

解决方案without using any modules that need downloading like turtle module,

rather id have to use the stddraw module

As @PurpleIce starts to get at, you've got this backward. The turtle module comes with Python, the stddraw module needs to be downloaded (from Princeton.)

Your question has inspired me to see if it is possible to make a minimalist working clock using Python turtle:

from time import localtime

from turtle import * # avoid wildcard imports like this

ATTRIBUTES = ['tm_hour', 'tm_min', 'tm_sec']

def tick():

record = localtime()

hands['tm_hour'].seth(record.tm_hour % 12 * 30 + record.tm_min / 2 + record.tm_sec / 120)

hands['tm_min'].seth(record.tm_min * 6 + record.tm_sec / 10)

hands['tm_sec'].seth(record.tm_sec * 6)

ontimer(tick, 1000)

mode("logo") # make 0 degrees be straight up the page

hands = {}

for size, attr in enumerate(ATTRIBUTES, start=1):

hands[attr] = Turtle('triangle')

hands[attr].shapesize(1 / size, size * 10)

tick()

mainloop()

Hopefully, this will give you insight on how to begin building your own clock using the stddraw module:

7kUUP.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值