Why is Python giving me “an integer is required” when it shouldn't be?

前端 未结 4 1109
自闭症患者
自闭症患者 2020-12-19 06:28

I have a save function within my Python program which looks like this:

def Save(n):
    print(\"S3\")
    global BF
    global WF
    global PBList
    globa         


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-19 06:53

    I'll bet that n is 1 not "1".

    try:

    print(type(n))
    

    I'll guess that you'll see its an int not a string.

    File = open("C:\KingsCapture\Saves\\" + n + "\BF.txt", "w")
    

    You can't add ints and strings producing the error message you are getting.

提交回复
热议问题