2.4x save load script to 2.7x

help me convert this blender 2.4x save load script to 2.7x

Save.py:

### Add objects to be saved to this list ###cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()


### Open the file "Game1.sav" in write mode
saveFile = open("Game1.sav", "w")
### Write header to file
saveFile.write("This is a valid save file
")


### Write game data to file
for x in range(len(cubePosi)):
	saveFile.write(str(cubePosi[x]) + "
")
for x in range(len(cubeRot)):
	for y in range(len(cubeRot[x])):
		saveFile.write(str(cubeRot[x][y]) + "
")


### Close save file
saveFile.close()

Load.py:

### Add objects to be saved to this list ###cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
cubePosi = cube.getPosition()
cubeRot = cube.getOrientation()


### Open the file "Game1.sav" in read mode
loadFile = open("Game1.sav", "r")
### Check for the header
header = loadFile.readline()
header = header[0:-1]


if header == "This is a valid save file":
	### Load game data from file
	for x in range(len(cubePosi)):
		loadCoord = loadFile.readline()
		cubePosi[x] = float(loadCoord[0:-1])
	cube.setPosition(cubePosi)
	for x in range(len(cubeRot)):
		for y in range(len(cubeRot[x])):
			loadCoord = loadFile.readline()
			cubeRot[x][y] = float(loadCoord[0:-1])
	cube.setOrientation(cubeRot)


### Close save file
loadFile.close()

That looks like it would be better completely re-written…looks like python2.x because file.close() was depreciated in 3.x I belive… and I assume you want to save and load more than the cube…

It does look like a good place to start though, for you to learn more python.

the globalDict is a good place to start with save and load.

Cotaks wrote a pretty good save load, I use it all the time. Look in resources. https://blenderartists.org/forum/showthread.php?359351-Save-and-Load-script-v3-0-by-cotax&highlight=save%2Fload+Cotax