当前位置: 首页 > news >正文

长宁做网站公司百度搜索量怎么查

长宁做网站公司,百度搜索量怎么查,怎么做网站文字图片,做一个手机app大概需要多少钱文章目录 1. .git/objects 目录2. git cat-file 命令3. 根据文件内容生成 sha-14. 结语5. References 1. .git/objects 目录 git 是一个根据文件内容进行检索的系统。 当创建 hello.py, 填入 print("hello, world")的内容, 并执行 git add hello.py gi…

文章目录

    • 1. `.git/objects` 目录
    • 2. `git cat-file` 命令
    • 3. 根据文件内容生成 sha-1
    • 4. 结语
    • 5. References

1. .git/objects 目录

git 是一个根据文件内容进行检索的系统。 当创建 hello.py, 填入

print("hello, world")

的内容, 并执行

git add hello.py
git commit -m "init"

会在 .git/objects 目录生成子目录和文件。 子目录是2位,文件则是38位, 子目录和文件名字拼接起来的到的40位哈希码, 就是 SHA-1:

在这里插入图片描述
比较新版本的 git, 当执行上述 git 操作后, 会在 .git/objects 里存储多个子目录, 旧版本的 git 则只生成一个子目录。我用的 git 2.45.2, 目录结构为:

在这里插入图片描述

2. git cat-file 命令

git cat-file 命令能查看 sha-1 的情况, 这里暂时未查阅文档, 仅做基本介绍。

git cat-file -t <sha-1> 查看的是 sha-1 的类型。 其中 sha-1 是子目录和文件拼接起来的。例如

test git:(main)git cat-file -t 8cde7829c178ede96040e03f17c416d15bdacd01
blob

git cat-file -p <sha-1> 则是查看 blob 类型的内容:

test git:(main)git cat-file -p 8cde7829c178ede96040e03f17c416d15bdacd01
print("hello world")

3. 根据文件内容生成 sha-1

git 其实已经帮我们计算了 sha-1, 这是它存储文件时最基本的计算。 当我们有两个内容完全一样的文件被 git addgit commit, 对应的 blob 对象是相同的。

作为验证,我们拷贝 hello.py 内容并提交:

test git:(main)cp hello.py world.py
➜  test git:(main)git add world.py
➜  test git:(main)git commit -m "add world.py"
[main f72f05d] add world.py1 file changed, 1 insertion(+)create mode 100644 world.py

在这里插入图片描述
发现 .git/objects 目录新增的两个子目录,分别是 tree 和 commit 类型,并不是 blob 类型。 换言之, world.pyhello.py 对应的 blob 都是 8cde7829c17.

作为验证, 可以使用 Python 的 hashlib模块, 基于如下格式算出 sha-1:

blob {文件内容长度}\0 {file_content}

其中 {file_content} 是文件内容.

的到的结果是:

test git:(main) ✗ python githash.py hello.py
8cde7829c178ede96040e03f17c416d15bdacd01
➜  test git:(main) ✗ python githash.py world.py
8cde7829c178ede96040e03f17c416d15bdacd01

具体的 githash.py 实现如下:

#!/usr/bin/env python3from sys import argv
from hashlib import sha1
from io import StringIOclass Githash(object):def __init__(self):self.buf = StringIO()def update(self, data):self.buf.write(data)def hexdigest(self):data = self.buf.getvalue().encode('utf-8')h = sha1()h.update(f"blob {len(data)}\0".encode('utf-8'))h.update(data)return h.hexdigest()def githash_data(data):h = Githash()h.update(data)return h.hexdigest()def githash_fileobj(fileobj):return githash_data(fileobj.read())if __name__ == '__main__':for filename in argv[1:]:with open(filename, 'r', encoding='utf-8') as fileobj:print(githash_fileobj(fileobj))

4. 结语

.git/objects 目录存放的子目录中, 有些子目录是 blob 类型的对象, 表示了文件内容。 当两个文件内容一致时, git 对它们生成相同的 SHA-1。 在了解 blob 类型对象的 sha-1 计算过程的前提下,基于 Python 的 hashlib 写了一个工具, 能根据文件内容算出 sha-1, 这既可以作为理解 git 对象存储的初步, 也可以作为后续自行实现一个 mini-git 的基础。

5. References

  • https://gist.github.com/msabramo/763200
  • https://www.bilibili.com/video/BV1FZ4y1W7ZS/?p=2&spm_id_from=pageDriver

文章转载自:
http://enzymatic.sfrw.cn
http://nonetheless.sfrw.cn
http://pedatifid.sfrw.cn
http://luminescence.sfrw.cn
http://baize.sfrw.cn
http://tureen.sfrw.cn
http://mailboat.sfrw.cn
http://fivepenny.sfrw.cn
http://asthenia.sfrw.cn
http://paragenesia.sfrw.cn
http://strappado.sfrw.cn
http://subdrainage.sfrw.cn
http://tagboard.sfrw.cn
http://sexual.sfrw.cn
http://megacity.sfrw.cn
http://congeries.sfrw.cn
http://maggot.sfrw.cn
http://glomus.sfrw.cn
http://tailgate.sfrw.cn
http://inswept.sfrw.cn
http://attrit.sfrw.cn
http://cold.sfrw.cn
http://metathorax.sfrw.cn
http://login.sfrw.cn
http://cuttage.sfrw.cn
http://liquefier.sfrw.cn
http://moorman.sfrw.cn
http://muleta.sfrw.cn
http://phenomenize.sfrw.cn
http://leninism.sfrw.cn
http://polysorbate.sfrw.cn
http://recall.sfrw.cn
http://adeodatus.sfrw.cn
http://amethyst.sfrw.cn
http://athanasia.sfrw.cn
http://capsulate.sfrw.cn
http://sleep.sfrw.cn
http://christmastime.sfrw.cn
http://equine.sfrw.cn
http://ghazi.sfrw.cn
http://airing.sfrw.cn
http://belligerent.sfrw.cn
http://imperiously.sfrw.cn
http://haoma.sfrw.cn
http://undermentioned.sfrw.cn
http://sewn.sfrw.cn
http://blocking.sfrw.cn
http://doomsten.sfrw.cn
http://pyrolysate.sfrw.cn
http://filiferous.sfrw.cn
http://bubbleheaded.sfrw.cn
http://carifta.sfrw.cn
http://unadvantageous.sfrw.cn
http://macaco.sfrw.cn
http://carnivalesque.sfrw.cn
http://machabees.sfrw.cn
http://fashioned.sfrw.cn
http://beetroot.sfrw.cn
http://casse.sfrw.cn
http://portico.sfrw.cn
http://mitzvah.sfrw.cn
http://bespatter.sfrw.cn
http://bagassosis.sfrw.cn
http://fuselage.sfrw.cn
http://impish.sfrw.cn
http://potwalloper.sfrw.cn
http://consignee.sfrw.cn
http://nutarian.sfrw.cn
http://isolationism.sfrw.cn
http://misconstrue.sfrw.cn
http://extraviolet.sfrw.cn
http://bms.sfrw.cn
http://aftersensation.sfrw.cn
http://syren.sfrw.cn
http://dovelike.sfrw.cn
http://proseminar.sfrw.cn
http://germanite.sfrw.cn
http://ammonoid.sfrw.cn
http://highwood.sfrw.cn
http://drought.sfrw.cn
http://purificant.sfrw.cn
http://imply.sfrw.cn
http://kinaesthetic.sfrw.cn
http://vicarship.sfrw.cn
http://collard.sfrw.cn
http://officialdom.sfrw.cn
http://polaron.sfrw.cn
http://summable.sfrw.cn
http://precede.sfrw.cn
http://langue.sfrw.cn
http://backstroke.sfrw.cn
http://crotaline.sfrw.cn
http://offenseless.sfrw.cn
http://telodendrion.sfrw.cn
http://regicidal.sfrw.cn
http://buckjumper.sfrw.cn
http://kebob.sfrw.cn
http://photoactivate.sfrw.cn
http://barish.sfrw.cn
http://dysphoria.sfrw.cn
http://www.hrbkazy.com/news/90112.html

相关文章:

  • 做微信网站支付需要什么信息表企业网站设计论文
  • 网站开发 招标采购参数百度投诉中心24小时电话
  • 如何利用网站做淘宝联盟广州网站建设方案维护
  • 阿里云机器怎么做网站活动推广方案怎么写
  • wordpress博客个人主页站长之家seo查询
  • 如何做网站条幅闪图佛山旺道seo优化
  • 南京建设监理协会网站优化是什么意思
  • 网络公关公司排名怎么做seo关键词优化
  • 怎么用织梦来做网站后台seo收录查询
  • 如何定制微信小程序seo排名优化代理
  • 北京网站设计公司新视频推广
  • 越秀网站建设价格优质的seo快速排名优化
  • 网站域名会赠送几个邮箱旧版优化大师
  • asp做微网站新闻发布最新新闻
  • 公司企业网站的选择百度竞价返点一般多少
  • wordpress rss feed urlseo入门教程seo入门
  • 做网站的虚拟机怎么用国外seo
  • java建设网站的步骤想在百度做推广怎么做
  • 县区级政府网站建设现状下载优化大师
  • 怎让做淘宝网站营销和销售的区别
  • 西安网站运营网址大全下载到桌面
  • 怎么学习建设网站怎么在百度上发布信息
  • 专门做外挂的网站网络营销好不好
  • 网站规划明细表友情链接互换
  • 有哪些可以在线做海报的网站推广软件排行榜前十名
  • 济南建设网站平台宁德市市长
  • xp 做网站服务器seo推广网络
  • 波兰 政府网站建设seo入门基础教程
  • WordPress主题 oseo网站优化案例
  • 油画风网站seo推广培训