コード例 #1
0
ファイル: a15.py プロジェクト: memo330179/GuessingGame
	def writeFile(self):
		"""Write the end result to the file"""
		fileN = open ("game.data","w")
		write_recursion.write(fileN, self.root)
		fileN.close()
		# this doesn't work for some reason
		with open("game.data", "r+w") as f:
			for line in f:
				if line.strip():
					f.write(line)
コード例 #2
0
 def writeFile(self):
     """Write the end result to the file"""
     fileN = open("game.data", "w")
     write_recursion.write(fileN, self.root)
     fileN.close()
     # this doesn't work for some reason
     with open("game.data", "r+w") as f:
         for line in f:
             if line.strip():
                 f.write(line)
コード例 #3
0
ファイル: test.py プロジェクト: memo330179/GuessingGame
from Tree import TreeNode
import write_recursion
sampleTree = TreeNode()

sampleTree.setValue(7)

sampleTree.addLeft(6)
sampleTree.addRight(10)
y = sampleTree.getLeft()
x = sampleTree.getRight()
x.addLeft(9)
x.addRight(57)

y.addLeft(8)
y.addRight(47)


def print_tree(tree):
    if tree == None:
        return
    print tree.item
    print_tree(tree.left)
    print_tree(tree.right)


print_tree(sampleTree)

gameData = open("testData.txt", "w")

write_recursion.write(gameData, sampleTree)
コード例 #4
0
ファイル: test.py プロジェクト: memo330179/GuessingGame
import write_recursion 
sampleTree = TreeNode()

sampleTree.setValue(7)



sampleTree.addLeft(6)
sampleTree.addRight(10)
y = sampleTree.getLeft()
x = sampleTree.getRight()
x.addLeft(9)
x.addRight(57)

y.addLeft(8)
y.addRight(47)


def print_tree(tree):
                if tree == None: 
                        return
                print tree.item
                print_tree(tree.left)
                print_tree(tree.right)

print_tree(sampleTree)

gameData = open("testData.txt", "w")

write_recursion.write(gameData, sampleTree)