抉择器

有没有拿不定主意的时候?有没有抛硬币来解决一个无关紧要的选择的习惯?

用python写了个类似抛硬币的程序,因为random.choice(),程序变的很简单:

 

  1. #coding: utf-8 
  2. # 
  3. import imp 
  4. import sys 
  5. import random 
  6. imp.reload(sys) 
  7. sys.setdefaultencoding('utf-8'#设置默认编码 
  8.  
  9. choiceList=[] 
  10.  
  11. print u"--------------------抉择器----------------------\n" 
  12. print u"输入你要选择的项(0:退出):" 
  13. while True
  14.     temp = raw_input("> "
  15.     if temp == "0"
  16.         break 
  17.     else
  18.         choiceList.append(temp) 
  19.         pass 
  20.  
  21. print '*'*10 
  22. print u"\n经过计算,选择了 \"" + random.choice(choiceList).decode("gbk").encode("utf-8") +"\""
  23.  

程序运行示例:

 

(说明:仅供娱乐、或者无关紧要的抉择,切莫在重大抉择时使用)

 

天哪,我是神经病

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章