Python

Snappy 压缩文本 安装 sudo apt-get install libsnappy-dev pip install python-snappy 使用 压缩文件 # compress python -m snappy -c uncompressed_file compressed_file.snappy # uncompress python -m snappy -d compressed_file.snappy uncompressed_file 压缩字符串 import snappy byte_data = snappy.snappy.compress(str_data) str_data = snappy.snappy.decompress(byte_data)
2020-04-13
1分钟阅读时长
安装 用于用 html 或 xml 字符串中提取数据 pip install bs4 使用 例如已经获得一下字符串 <html> <head> <title> The Dormouse's story </title> </head> <body> <p class="title"> <b> The Dormouse's story </b> </p> <p class="story"> Once upon a time there were three little sisters; and their names were <a class="sister" href="http://example.com/elsie" id="link1"> Elsie </a> , <a class="sister" href="http://example.com/lacie" id="link2">
2020-03-25
1分钟阅读时长
yield 当函数中有 yield 时,运行该函数不会运行,而会返回一个<generator object>。 使用 next(func_ret_object) 将函数运行至第一个 yield 处。 使用 w = func_ret_object.send(value) 将数据传入处
2019-12-27
1分钟阅读时长
Model 相关操作 反向外键 class DictKanaItem(models.Model): # .... class DictKanjiItem(models.Model): kana = models.ForeignKey('DictKanaItem', related_name='kanji', on_delete=models.PROTECT) # Onetoone 同理 update_date = models.DateField('更新时间', auto_now=True) create_time = models.DateTim
2019-09-09
2分钟阅读时长