私はPython 2.7でスクリプトを開発しています。私はスクリプトがgithubを介して常に最新であることを確認したい。 私が試したのは、github上に最新のバージョン番号を入れたファイルを作成し、pythonスクリプトでそのファイルをダウンロードし、プログラムのバージョン番号と比較することです。これは現在のスクリプトですが、実際には機能しません。Pythonでスクリプト/プログラムのバージョンを確認してください。
import sys
import os
import urllib
current_version = """1.4"""
print ("\a")
print ("Checking for latest verion..")
urllib.urlretrieve ("https://raw.githubusercontent.com/[myname]/[myproject]/master/version_latest", "version_latest")
version = open('version_latest', 'r').read()
if version == current_version:
vlatest = "1"
else:
vlatest = "2"
if vlatest == 2:
print ("Please get the latest version of this program here:")
print ("https://github.com/[myname]/[myproject]")
print ("You can't use the program without it!")
print ("\a")
os.system("start https://github.com/[myname]/[myproject]")
raw_input("Press enter to exit")
sys.exit()
else:
print ("You have the latest verion! Program will start automaticly!")
ありがとうございます!
'vlatest'(文字列)と' 2'を比較しています。 'if'は常に' else'ブランチに入ります。 –