摘要: 一、添加表记录 创建方式1: from django.shortcuts import render from homework1 import models def index(request): #book_obj自定义类对象 book_obj = models.BookInfo( id=2, 阅读全文
posted @ 2021-01-09 11:43 中南毛毛虫 阅读(165) 评论(0) 推荐(0)
摘要: 查看模块下的所有方法 dir(模块名/包名) 例如: import os import multiprocessing print(dir(os)) print(dir(multiprocessing)) 阅读全文
posted @ 2020-11-21 19:05 中南毛毛虫 阅读(64) 评论(0) 推荐(0)
摘要: 一、json模块 作用:将内置的数据类型,如int\tuple\list\dic(set, class不行),进行序列化或反序列化 dumps\loads方法主要用于网络传输,有时也用来读取文件。用于一般数据结构数据与json字符串相互转换 import json # 1.将一般数据结构转化成jso 阅读全文
posted @ 2020-11-16 21:19 中南毛毛虫 阅读(67) 评论(0) 推荐(0)
摘要: 一、__call__方法 class A(): def __call__(self, *args, **kwargs): print("我的名字叫做中南毛毛虫") # 于是便可以进行以下的操作: mkc = A() mkc() A()() 二、__len__方法 class Class(): def 阅读全文
posted @ 2020-11-16 16:48 中南毛毛虫 阅读(99) 评论(0) 推荐(0)
摘要: 一、反射对象的实例变量/绑定方法 import time class Perosn(): def __init__(self, name, birth): self.name = name self.birth = birth @property def age(self): return time 阅读全文
posted @ 2020-11-15 20:56 中南毛毛虫 阅读(91) 评论(0) 推荐(0)
摘要: 1、unicode、utf-8、gbk之间的相互转换 aa = '今天的天气是多云' # utf-8到Unicode b = aa.encode('utf-8') print(b) # Unicode到utf-8 c = b.decode('utf-8') print(c) # Unicode到gb 阅读全文
posted @ 2020-11-15 09:45 中南毛毛虫 阅读(41) 评论(0) 推荐(0)
摘要: 一、os.path相关 os.path.join(path, str)--拼接路径 os.path.isdir(path)--判断是不是文件夹 os.path.isfile(path)--判断是不是文件 os.path.dirname(file) --当前文件目录的父目录 os.path.getsi 阅读全文
posted @ 2020-11-11 19:28 中南毛毛虫 阅读(147) 评论(0) 推荐(0)
摘要: import re exp = '<mkc>hajsdbfjkasnfk&*jnfkjgkjdfngj</mkc>89645860ghidngkj&()gd4</666>' # 1. 分组优先显示,针对于findall ret1 = re.findall('<\w+>(.*?)</\w+>', ex 阅读全文
posted @ 2020-11-11 16:29 中南毛毛虫 阅读(75) 评论(0) 推荐(0)