随笔分类 - python
摘要:解决 pandas.to_csv 乱码、丢失行和自动换行问题-百度开发者中心 https://developer.baidu.com/article/details/2792989 在使用 pandas.to_csv 函数时,可能会遇到一些问题,如乱码、丢失行和自动换行等。这些问题通常是由于编码格式
阅读全文
摘要:s = ''' [ { label: "苹果", value: "origin_event_data", icon: "icon-a", color: "#409EFF", bgColor: "#ECF5FF", borderColor: "#D9ECFF", }, { label: "橘子", v
阅读全文
摘要:Generics — typing documentation https://typing.python.org/en/latest/reference/generics.html You may have seen type hints like list[str] or dict[str, i
阅读全文
摘要:assert在Python优化模式(-O)下会被全局禁用 应改用显式的if/raise结构抛出业务异常(如ValueError) 翻译 搜索 复制
阅读全文
摘要:import contextlibimport threadingimport timeclass TimeoutException(Exception): passdef raise_exception(): raise TimeoutException("Time out")@contextli
阅读全文
摘要:Python 类变动的钩子方法 from typing import Listclass Field: def __init__(self, name, is_user=False): self.name = name self.is_user = is_user def __str__(self)
阅读全文
摘要:isort https://pycqa.github.io/isort/ isort · PyPI https://pypi.org/project/isort/ Before isort: from my_lib import Object import os from my_lib import
阅读全文
摘要:实践: 测试用例 @dataclasses.dataclassclass TestCase: method: str path: str cid: int data: dict query_str: str resp: dict = dataclasses.field(default_factory
阅读全文
摘要:def defer(msg: str, subject='参数错误'): print('do ') return f'{subject}:{msg}'assert False, defer('66') Python 实现类似于Go语言中的延迟执行语句(defer)|极客笔记 https://deep
阅读全文
摘要:s = 'abcaabc's = s.rstrip('abc') #!/usr/bin/python# -*- coding: UTF-8 -*- random_string = 'this is good ' # 字符串末尾的空格会被删除print(random_string.rstrip())
阅读全文
摘要:The Art of Graceful Reloading — uWSGI 2.0 documentation https://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html 翻译 搜索 复制
阅读全文
摘要:如果 ensure_ascii 是 true (即默认值),输出保证将所有输入的非 ASCII 字符转义。如果 ensure_ascii 是 false,这些字符会原样输出。 If ensure_ascii is true (the default), the output is guarantee
阅读全文
摘要:numpy判断 import numpy as np nan = float('nan') print(np.isnan(nan)) 翻译 搜索 复制
阅读全文
摘要:Standard Library Types - Pydantic https://docs.pydantic.dev/2.7/api/standard_library_types/#typeddict from pydantic import BaseModelfrom typing import
阅读全文
摘要:l=[{'a':45},{"b":34}]c=0for i in l: i['a']=c*100 c+=1 * 翻译 搜索 复制
阅读全文
摘要:class Test: def __init__(self, totals, uniques, pre): self.totals = totals self.uniques = uniques self.cumulative_sum = totals if pre: self.cumulative
阅读全文
摘要:MicroPython - Python for microcontrollers https://micropython.org/ 翻译 搜索 复制
阅读全文
摘要:print 翻译 搜索 复制
阅读全文
摘要:in-memory analytics Apache Arrow Apache Arrow is a development platform for in-memory analytics. It contains a set of technologies that enable big dat
阅读全文