摘要:
测试函数 1.导入模块 import unittest 2.创建类 class NameTestcase(unittest.TestCase) def test_name(self:) """各种断言""" assertEqual(a, b) 核实a == b assertNotEqual(a, b 阅读全文
摘要:
bytes > encode(编码) > 字符串 字符串 > decode(解码) > bytes #bytes(要转换成bytes的字符串,一定要指定编码模式encoding = 'utf-8') 打开文件: with open('a.txt','r',encoding='utf-8') as f 阅读全文
摘要:
(1) 传递任意数量的实参: 形参名*args 中的星号让Python创建一个名为args的空元组,并将收到的所有值都封装到这个元组中。 **kwargs 让Python创建一个名为args的空字典(args和kwargs只是名称,可以自定义) 实例: # 使用*args def test_args 阅读全文
摘要:
数字 int 方法: int('123')将其他类型的数字转换为数字 int(10,base=2,8,16) 按照指定进制转换 .bit_length() 输出变量至少需要几位比特位 字符串:一旦创建不可修改,一旦修改、拼接就会生成新的字符串 方法: 0. isdigit() 检测字符串是否只由数字 阅读全文