Python Forum
Getting int from file instead of randomgenerator
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting int from file instead of randomgenerator
#11
(Jan-25-2018, 06:07 AM)j.crater Wrote: If your text file only has one string (the integer you want), then this will suffice:
x = 0
with open('key.txt', 'r') as file:
    number = file.readline().rstrip('\n')
    x = int(number)
It is good you decided to do things on your own as part of learning process. You can post PyQt related questions in the GUI subforum.
Thanks for the support j.crater!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020