0

i've tried to implement an auto update check into my Python programm. I want to achieve this by reading the content of a TXT file i hosted on my website (containing just "1.0" ) and checking it with a local variable.

So far i actually got everything working fine. however when i run the script, this is what it reads from the TXT file online

b'1.0'

This is the code i try to achieve this with

import urllib.request
import urllib
CurrentGameVersion = "1.0"
def updateGame():
 with urllib.request.urlopen('http://myWebsite.de/version.txt') as response:
    version = response.read()
if version != CurrentGameVersion:
    print ("Update pls")
    print (version)
    print (CurrentGameVersion)
else:
    print ("Up to Date!")

As i said, print (version) prints out b'1.0' while print (CurrentGameVersion) obviously prints out 1.0

1Day2Die
  • 29
  • 9

1 Answers1

0

Your response.read() call is returning a bytes object, the 'b' at the start of the value indicates that. You should call string.decode() to decode this value. Try this line instead:

    version = response.read().decode('utf-8')
Steve Boyd
  • 1,287
  • 11
  • 17