Python3源码学习-requests

源码:https://github.com/small99/AutoLink

本地安装包 version.txt记录版本号。

通过requests GET最新git上版本号。

import codecs
import requests


def check_version():
    with codecs.open('version.txt', 'r') as fd:
        version = fd.readline()

    s = requests.Session()
    r_version = s.get("https://gitee.com/lym51/AutoLink/raw/master/version.txt").text
    if version != r_version:
        print("*" * 25)
        print("本地版本:v%s" % version)
        print("github版本: v%s" % r_version)
        print("AutoLinK开源平台代码已有更新,请到下面的地址更新代码:")
        print("下载最新代码,直接覆盖本地即可")
        print("https://github.com/small99/AutoLink")
        print("*" * 25)
        exit(0)


check_version()

  

猜你喜欢

转载自www.cnblogs.com/zhangwei22/p/10161445.html