I have a save function within my Python program which looks like this:
def Save(n):
print("S3")
global BF
global WF
global PBList
global PWList
print(n)
File = open("C:KingsCaptureSaves" + n + "BF.txt", "w")
pickle.dump(BF, File)
File = open("C:KingsCaptureSaves" + n + "WF.txt", "w")
pickle.dump(WF, File)
File = open("C:KingsCaptureSaves" + n + "PBList.txt", "w")
pickle.dump(PBList, File)
File = open("C:KingsCaptureSaves" + n + "PWList.txt", "w")
pickle.dump(PWList, File)
Here, n is "1".
I get an error looking like this:
File "C:/Python27/KingsCapture.py", line 519, in Save
File = open("C:KingsCaptureSaves" + n + "BF.txt", "w")
TypeError: an integer is required
Upon doing the same loading within the shell, I get no errors:
>>> File = open("C:KingsCaptureTestList.txt", "r")
>>> File = open("C:KingsCaptureTestList.txt", "w")
>>> n = "1"
>>> File = open("C:KingsCaptureSaves" + n + "BF.txt", "r")
>>> File = open("C:KingsCaptureSaves" + n + "BF.txt", "w")
Why is this having a problem?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…