-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.json
More file actions
1 lines (1 loc) · 6.29 KB
/
index.json
File metadata and controls
1 lines (1 loc) · 6.29 KB
1
[{"content":"\r为什么使用? 在网站搭建的md文件中,需要时常的更新图片,一次次打标签插入图片过于麻烦 另外保存图片往往需要另存为,还需要考虑图片的路径比较麻烦 \u0026lt;img src=\u0026#34;\\images\\2024-05-06-16-06-38.png\u0026#34; width=\u0026#34;50%\u0026#34; height=\u0026#34;50%\u0026#34;\u0026gt; - 基础概念 static 静态文件夹里的东西 复制至 public - 只需在static里 建文件夹 然后 \\images表示的是public里面的文件 怎么使用? 1.ctrl+shift+p 2.搜索 paste image 直接出现img标签\n如何设置? 打开 Extension 里面的 setting 参数的解释 ","permalink":"https://python-users.github.io/posts/blog/paste_image/","summary":"为什么使用? 在网站搭建的md文件中,需要时常的更新图片,一次次打标签插入图片过于麻烦 另外保存图片往往需要另存为,还需要考虑图片的路径比较麻烦 \u0026lt;img src=\u0026#34;\\images\\2024-05-06-16-06-38.png\u0026#34; width=\u0026#34;50%\u0026#34; height=\u0026#34;50%\u0026#34;\u0026gt; - 基础概念 static 静态文件夹里的东西 复制至 public - 只需在static里 建文件夹 然后 \\images表示的是public里面的文件 怎么使用? 1.ctrl+shift+p 2.","title":"Paste_image"},{"content":"发现插件VSCODE可以直接复制图片到文件夹 第二章 ","permalink":"https://python-users.github.io/posts/tech/fluent2/","summary":"发现插件VSCODE可以直接复制图片到文件夹 第二章","title":"Fluent_Python_book-2"},{"content":"第一章 问题 1.什么是魔法方法? 2.如何使用魔法方法? 3.为什么要用魔法方法? #引入collection类 import collections Card = collections.namedtuple(\u0026#39;Card\u0026#39;,[\u0026#39;rank\u0026#39;,\u0026#39;suit\u0026#39;]) class FrenchDeck: #创建列表,这个列表为 [2,3,4,5,6,7,8,9,10,J,Q,K,A] ranks = [str(n) for n in range(2,11)] + list(\u0026#39;JQKA\u0026#39;) #创建花色 suits = \u0026#39;spades diamonds clubs hearts\u0026#39;.split() def __init__(self): self._cards = [Card(rank,suit) for suit in suits for rank in self.ranks] #len和get_item让这个纸牌变成一个可以迭代的对象 def __len__(self): return len(self._cards) def __getitem__(self,position): return self._cards[position] #可以进行的操作 deck = FrenchDeck() #可以取值,可以知道牌的长度 print(len(deck)) deck[0] deck[-1] deck[1:3] #可以随机取 from random import choice choice(deck) #可以这个理解现在这个类的实例已经完全变成了一个列表,列表里有很多个小的对象 **排序**有难度 suit_value = dict(spades =2,hearts =2,diamonds =1,clubs=0) def spades_high(card): **定位** #还是有一些迷惑??? 迷惑点为什么*len(suit_values) rank_value = FrenchDeck.ranks.index(card.rank) return rank_value * len(suit_values) + suit_values[card.suit] for card in sorted(deck,key=spades_high):#key传出的应该是一个能够返回当前对象的权重值的函数 print(card) 1.什么是魔法方法?\n魔术方法是双下划线方法,目前看来,是给类做一些外衣可以让它变成一些Python自有的数据序列,从而具有相应的功能。类似于铠甲勇士变身。 2.如何使用魔法方法?\n它是自己调用的,不需要你调用函数,调用是隐式的。 不要随意添加特殊方法。 #向量相加 from math import hyport class Vector(): def __init__(self,x,y): self.x = x self.y = y def __repr__(self): return \u0026#39;Vector({},{})\u0026#39;.format(self.x,self.y) def __abs__(self): return hyport(self.x,self.y) def __bool__(self): return bool(abs(self)) def __add__(self,other): x = self.x + other.x y = self.y + other.y return Vector(x,y) def __mul__(self,scalar): return Vector(self.x*scalar,self.y*scalar) 问题 __repr__ 与 __str__ 的区别? 先跳过 一个是 通过 print 或 str() 调用 Python对象的一个基本要求就是它得有合理的字符串表示形式,我们可以通过__repr__和__str__来满足这个要求。 前者方便我们调试和记录日志,后者则是给终端用户看的。这就是数据模型中存在特殊方法__repr__和__str__的原因。 ","permalink":"https://python-users.github.io/posts/tech/fluent1/","summary":"第一章 问题 1.什么是魔法方法? 2.如何使用魔法方法? 3.为什么要用魔法方法? #引入collection类 import collections Card = collections.namedtuple(\u0026#39;Card\u0026#39;,[\u0026#39;rank\u0026#39;,\u0026#39;suit\u0026#39;]) class FrenchDeck: #创建列表,这个列表为 [2,3,4,5,6,7,8,9,10,J,Q,K,A] ranks = [str(n) for n in range(2,11)] + list(\u0026#39;JQKA\u0026#39;) #创建花色 suits = \u0026#39;spades diamonds clubs hearts\u0026#39;.split() def __init__(self): self._cards = [Card(rank,suit) for suit in suits for rank in self.ranks] #len和get_item让这个纸牌变成一个可以迭代的对象 def __len__(self): return len(self._cards) def __getitem__(self,position): return","title":"Fluent_Python_book-1"},{"content":"","permalink":"https://python-users.github.io/posts/life/life/","summary":"","title":"Life"},{"content":"","permalink":"https://python-users.github.io/posts/read/read/","summary":"","title":"Read"},{"content":"\rSulv\u0026#39;s Blog\r一个记录技术、阅读、生活的博客\r👉友链格式\r名称: Sulv\u0026rsquo;s Blog 网址: https://www.sulvblog.cn 图标: https://www.sulvblog.cn/img/Q.gif 描述: 一个记录技术、阅读、生活的博客 👉友链申请要求\r秉承互换友链原则、文章定期更新、不能有太多广告、个人描述字数控制在15字内\n👉Hugo博客交流群\r787018782\n","permalink":"https://python-users.github.io/links/","summary":"Sulv\u0026#39;s Blog 一个记录技术、阅读、生活的博客 👉友链格式 名称: Sulv\u0026rsquo;s Blog 网址: https://www.sulvblog.cn 图标: https://www.sulvblog.cn/img/Q.gif 描述: 一个记录技术、阅读、生活的博客 👉友链申请要求 秉承互换友链原则、文章定期更新、不能有太多广告、个人描述字数控制在15字内 👉Hugo博客交流群 787018782","title":"🤝友链"},{"content":"关于我\n英文名: zhanglei 职业: 自由 运动: 跑步、网球、吉他 ","permalink":"https://python-users.github.io/about/","summary":"关于我 英文名: zhanglei 职业: 自由 运动: 跑步、网球、吉他","title":"🙋🏻♂️关于"}]