首页 > 不知道选哪个offer?offer算命代码来了!
头像
热爱生活的小熊猫
编辑于 2020-09-26 22:46
+ 关注

不知道选哪个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()


全部评论

(5) 回帖
加载中...
话题 回帖

推荐话题

相关热帖

历年真题 真题热练榜 24小时
技术(软件)/信息技术类
查看全部

近期精华帖

热门推荐