DAY 42 前端

 

json序列化

import json
from datetime import date,datetime


class MyJsonEncoder(json.JSONEncoder):
   def default(self, o):
       # o其实就是我们即将要序列化的对象
       if isinstance(o,date):
           return o.strftime('%Y-%m-%d')
       if isinstance(o,datetime):
           return o.strftime('%Y-%m-%d %X')
       return o

d = {'time1':date.today(),'time2':datetime.today()}
res = json.dumps(d,cls=MyJsonEncoder)
print(res)
"""
TypeError: Object of type date is not JSON serializable
"""

面试题

class Context:
   def __enter__(self):
       print('嘿嘿嘿')
       return self
   def __exit__(self, exc_type, exc_val, exc_tb):
       print('呵呵呵')
   def do_something(self):
       pass
with Context() as obj:
   print('哈哈哈')
   print(obj)

jQuery

1.使用js文件存储
2.html文件需要先导入才能使用
3.jQuery使用$代替,增加书写简易度

CDN

内容分发网络

常用选择器

  • 基本选择器

  • 组合选择器

  •  

posted @   DEJAVU_ERIC  阅读(25)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
点击右上角即可分享
微信分享提示