Created
December 4, 2011 11:35
-
-
Save poochin/1429967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # threading base code | |
| # http://techno-st.net/2010/02/06/python-3.html | |
| ''' | |
| スタープラチナ Vs. ザ・ワールド | |
| Version 1.0.0 | |
| ''' | |
| import sys | |
| import threading | |
| class LoopShout(threading.Thread): | |
| def __init__(self, shout): | |
| threading.Thread.__init__(self) | |
| self.setDaemon(True) | |
| self.shout = shout | |
| self.count = 0 | |
| self.interrupt = False | |
| def run(self): | |
| while not self.interrupt: | |
| sys.stdout.write(self.shout) | |
| self.count += 1 | |
| if __name__ == '__main__': | |
| star, world = (LoopShout('オラ'), LoopShout('無駄')) | |
| star.start() | |
| world.start() | |
| try: | |
| while True: | |
| pass | |
| except KeyboardInterrupt: | |
| star.interrupt = True | |
| world.interrupt = True | |
| print "\n" | |
| print "空条承太郎: %d [発]" % (star.count) | |
| print "ディオ: %d [発]" % (world.count) | |
| if star.count == world.count: | |
| print "【引き分け】" | |
| elif star.count > world.count: | |
| print "【空条承太郎の勝ち】" | |
| else: | |
| print "【ディオ・ブランドーの勝ち】" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment