Opening Files in python an integer is required error

时间:2016-04-04 17:44:09

标签: python-3.x text-files

I am trying to open a file in python but I keep getting the error "an integer is required"

My code:

    print("This is console module")

    import random

    def randomNumber(myFile):


    times=0

    print("Generating numbers...")

       while times != 10:
           random=random.randint(1, 100)
           print("\nNumber generated: "+str(random))
           myFile.write(random)
           times+1

       myFile.close()
       print("Done")




   myFile = open("NUMBERS.TXT", "a", "wt", "rt")

   randomNumber(myFile)

   myFile.close()

I want it to print random numbers to a file

0 个答案:

没有答案