Chinaunix

标题: 语音报时程序[pyton] [打印本页]

作者: yishanju    时间: 2007-03-30 15:44
标题: 语音报时程序[pyton]
  1. #coding:cp936
  2. import time,winsound
  3. time=time.localtime()
  4. h=time[3]
  5. m=time[4]
  6. def sound(wav):
  7.     path="sound\\%s.wav" % wav
  8.     winsound.PlaySound(path,winsound.SND_NODEFAULT)
  9. th=str(h)
  10. lenth=len(th)
  11. th0=th[0]
  12. if lenth==2:
  13.     th1=th[1]
  14. tm=str(m)
  15. lentm=len(tm)
  16. tm0=tm[0]
  17. if lentm==2:
  18.     tm1=tm[1]
  19.    
  20. sound("now")
  21. if lenth==1:
  22.     sound(th)
  23. elif lenth==2 and th=="10":
  24.     sound("10")
  25. elif lenth==2 and th=="20":
  26.     sound("2")
  27.     sound("10")
  28. elif lenth==2 and h<20:
  29.     sound("10")
  30.     sound(th1)   
  31. elif lenth==2 and h>20:
  32.     sound(th[0])
  33.     sound("10")
  34.     sound(th[1])
  35. else:
  36.     print "I服了YOU!"
  37. sound("hour")
  38. if m==0:
  39.     sound("just")
  40. elif m==10:
  41.     sound("10")
  42.     sound("minute")
  43. elif m>10 and tm1=="0":
  44.     sound(tm0)
  45.     sound("10")
  46.     sound("minute")
  47. elif m<10 and m!=0:
  48.     sound("0")
  49.     sound(tm0)
  50.     sound("minute")
  51. elif m>10 and m<20:
  52.     sound("10")
  53.     sound(tm1)
  54.     sound("minute")
  55. elif m>20:
  56.     sound(tm0)
  57.     sound("10")
  58.     sound(tm1)
  59.     sound("minute")
复制代码

语音报时.rar

99.37 KB, 下载次数: 194


作者: ghostwwl    时间: 2007-04-15 14:50
这个可以该进的  你不感觉 每次时间中间有点卡卡的??

很简单的 自己想想 可以改进一点点的
作者: wibrst    时间: 2007-04-15 19:42
群里随时可以讨论:"动态语言研究社"群号:38663927
作者: yishanju    时间: 2007-04-16 23:20
原帖由 ghostwwl 于 2007-4-15 14:50 发表
这个可以该进的  你不感觉 每次时间中间有点卡卡的??

很简单的 自己想想 可以改进一点点的




这个程序不打算做得很好
因为没有实际的需要来驱动我把这个程序写得非常好
这个程序只是我非常无聊的时候写的

不过你要是直接告诉我怎么做就好了




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2