herrDeng網內搜尋

自訂搜尋

Ads

2022年11月13日 星期日

python用dict, tuple實作opencv 12星座


魔羯座 (12月21日 - 1月20日)
水瓶座 (1月21日 - 2月18日)
雙魚座 (2月19日 - 3月20日)
白羊座 (3月21日 - 4月19日)
金牛座 (4月21日 - 5月21日)
雙子座 (5月22日 - 6月21日)
巨蟹座 (6月22日 - 7月22日)
獅子座 (7月23日 - 8月22日)
處女座 (8月23日 - 9月22日)
天秤座 (9月23日 - 10月23日)
天蠍座 (10月24日 - 11月21日)
射手座 (11月22日 - 12月20日)


圖檔取於wiki,簡化教學版程式在下面請打開
  1. #以下為教學程式
  2. x={}
  3. xx=('摩羯座', 20, 'Capricorn')
  4. x.update({12: xx})
  5. x
  6. xx=('摩羯座', 20, 'Capricorn')
  7. x.update({0: xx})
  8. x
  9. x.update( {1: ('水瓶座', 18, 'Aquarius'),
  10. 2: ('雙魚座', 20, 'Pisces'),
  11. 3: ('牡羊座', 19, 'Aries'),
  12. 4: ('金牛座', 20, 'Taurus'),
  13. 5: ('雙子座', 21, 'Gemini'),
  14. 6: ('巨蟹座', 22, 'Cancer'),
  15. 7: ('獅子座', 22, 'Leo'),
  16. 8: ('處女座', 22, 'Virgo'),
  17. 9: ('天秤座', 23, 'Libra'),
  18. 10: ('天蠍座', 21, 'Scorpio'),
  19. 11: ('射手座', 20, 'Sagittarius')})
  20. x
  21. x.keys()
  22. x.values()
  23. x.items()
  24.  
  25. mm=int(input('mm=?'))
  26. dd=int(input('dd=?'))
  27.  
  28. #這裡需要修正
  29. if dd<=x[mm-1][1]:
  30. zz=mm-1
  31. else:
  32. zz=mm
  33. if zz==0:
  34. zz=12
  35.  
  36. print( x[zz][0],x[zz][2], '結束於',zz%12+1,'月',x[zz][1])
  37. #星座圖檔請自行做相對應處理1.png ...12.png
  1. import cv2
  2. im=cv2.imread(str(zz)+'.png')
  3. cv2.imshow('z', im)
  4. cv2.waitKey(0)
  5. cv2.destroyAllWindows()

沒有留言:

Related Posts Plugin for WordPress, Blogger...

熱門文章