1
我有一些像這樣的代碼:比較數字
def checkupdate():
build_version = 1.8
server = 'server ip'
ftp2 = ftplib.FTP(server)
ftp2.login()
writeversion = open("latest_version.txt", "w")
ftp2.retrlines('RETR latest_version.txt', writeversion.write())
writeversion.write(latestversion)
writeversion.close()
latestversion2 = open("latest_version.txt", "r")
latestversion3 = latestversion2.readline()
if latestversion3 > build_version:
tkMessageBox.showwarning("Updater", "There is a new version. Please check our site.")
elif latestversion3 == build_version:
tkMessageBox.showinfo("Updater", "Current version:%d, is the latest." % build_version)
else:
tkMessageBox.showinfo("Updater", "Current version:%d is the latest." % build_version)
latestversion2.close()
os.unlink("latest_version.txt")
然而,每次我運行它,它不能寫的版本從FTP服務器取到latest_version.txt,並且該文件是空的。它也告訴我有總是一個新版本。任何方式讓這件作品?
你能修好你的縮進嗎? – usethedeathstar
@usethedeathstar固定 – user3167683
有些部分仍然不固定? (if/elif/else部分) – usethedeathstar