不知道选哪个offer?offer算命代码来了!
最近秋招拿了几个offer,都差不太多,于是就很纠结该选哪一个,辗转反侧之间发现牛客网的牛友们也有同样的烦恼,于是乎我决定写一个God Bless You自动选择offer代码,解决你的烦恼.献出代码
""" @Author: Howard Wonanut Do not know how to select your future job? Let me help you :) """ import hashlib import random import re import urllib from bs4 import BeautifulSoup # Modify your name here. NAME = 'len' # Modify your job list here. JOB_LIST = ["tplink", "shopee", "tencent", "bytedance", "huawei"] # Modify the path of this script. SCRIPT_PATH = "./guess_which_job.py" # Modify your random seed here. def getRandomSeed(): soup = BeautifulSoup(urllib.request.urlopen('http://www.weather.com.cn/weather/101110101.shtml').read().decode('utf-8'), 'html.parser') return re.search("<i>(.*?)</i>", str(soup.find_all("p", class_="tem")[0]))[1][:-1] # Do not modify the core function! def readScript(file_path): content = "" with open(file_path, 'r') as file: for line in file.readlines(): content += line.strip() return content # Do not modify the core function! def generateJob(): if len(JOB_LIST) == 0: print("There will be bread, there will be milk, everything will be there!") return random.seed(getRandomSeed()) random.shuffle(JOB_LIST) print("Hi %s, your target job is: %s" % (NAME, JOB_LIST[int(str(hashlib.new('sha1', readScript(SCRIPT_PATH).encode(encoding='UTF-8')).hexdigest()), 16) % len(JOB_LIST)])) if __name__ == "__main__": generateJob()