摘要: 测试函数 1.导入模块 import unittest 2.创建类 class NameTestcase(unittest.TestCase) def test_name(self:) """各种断言""" assertEqual(a, b) 核实a == b assertNotEqual(a, b 阅读全文
posted @ 2020-06-13 17:35 pywhy 阅读(129) 评论(0) 推荐(0) 编辑
摘要: bytes > encode(编码) > 字符串 字符串 > decode(解码) > bytes #bytes(要转换成bytes的字符串,一定要指定编码模式encoding = 'utf-8') 打开文件: with open('a.txt','r',encoding='utf-8') as f 阅读全文
posted @ 2020-06-13 17:33 pywhy 阅读(125) 评论(0) 推荐(0) 编辑
摘要: (1) 传递任意数量的实参: 形参名*args 中的星号让Python创建一个名为args的空元组,并将收到的所有值都封装到这个元组中。 **kwargs 让Python创建一个名为args的空字典(args和kwargs只是名称,可以自定义) 实例: # 使用*args def test_args 阅读全文
posted @ 2020-06-13 17:32 pywhy 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 数字 int 方法: int('123')将其他类型的数字转换为数字 int(10,base=2,8,16) 按照指定进制转换 .bit_length() 输出变量至少需要几位比特位 字符串:一旦创建不可修改,一旦修改、拼接就会生成新的字符串 方法: 0. isdigit() 检测字符串是否只由数字 阅读全文
posted @ 2020-06-13 17:29 pywhy 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 富文本编辑框:编辑框是一个插件,有多种,这里使用kind editor 一、从官网下载插件 - http://kindeditor.net/doc.php - Django下插件中的有些目录无需使用,可以删除 - asp - ASP程序 - asp.net - ASP.NET程序 - php - P 阅读全文
posted @ 2019-11-01 09:08 pywhy 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 一、用户登录验证 - 验证两次密码输入是否一致 - 自定制密码验证规则(必须包含字母、数字和特殊字符) - 验证码的使用 - 免登录期限 views.py 1 from django.http import HttpResponse 2 from django.shortcuts import re 阅读全文
posted @ 2019-10-31 08:43 pywhy 阅读(369) 评论(0) 推荐(0) 编辑
摘要: alien_invasion.py import pygame from pygame.sprite import Sprite class Ship(Sprite): def __init__(self,ai_settings,screen): super().__init__() self.sc 阅读全文
posted @ 2019-07-23 20:15 pywhy 阅读(210) 评论(0) 推荐(0) 编辑
摘要: import random def code_creat(): codes = '' """创建四位验证码""" for n in range(4): current = random.randrange(0,4) if current != n: code_o = str(random.randint(0,9))... 阅读全文
posted @ 2019-07-23 20:01 pywhy 阅读(140) 评论(0) 推荐(0) 编辑