Python Forum

Full Version: Getting int from file instead of randomgenerator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
(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!
Pages: 1 2