当前位置:首页>python>Python 30个实用技巧,早用早知道,提升效率

Python 30个实用技巧,早用早知道,提升效率

  • 2026-06-29 02:49:37
Python 30个实用技巧,早用早知道,提升效率

Python 写多了会慢慢发现,语法本身藏着不少好用的东西,但不是每个人都会去翻文档把它们挖出来。下面整理了 30 个从基础到进阶的技巧,每条附带可直接跑的代码,按需取用。

往期阅读>>>

Python 20 个文本分析的库:效率提升 10 倍的秘密武器

Python 金融定价利器FinancePy库深度解析

Python 适合新手的量化分析框架AKQuant解析
Python 25个数据清洗技巧:让你的数据质量提升10倍

Python 为什么会成为AI时代的头部语言

Python 40个常用的列表推导式

Python 50个提高代码开发效率的方法

Python 自动检测服务HTTPS证书过期时间并发送预警

Python 自动化操作Redis的15个实用脚本

Python 自动化管理Jenkins的15个实用脚本,提升效率

Python copyparty搭建轻量的文件服务器的方法

Python 实现2FA认证的方法,提升安全性

Python 封装20个常用API接口,提升开发效率

App2Docker:如何无需编写Dockerfile也可以创建容器镜像

Python 集成 Nacos 配置中心的方法

Python 35个JSON数据处理方法

Python 字典与列表的20个核心技巧

Python 15个文本分析的库,提升效率

Python 15个Pandas技巧,提升数据分析效率

Python 运维中30个常用的库,提升效率

Python调用远程接口的方法

Python 提取HTML文本的方法,提升效率

Python 应用容器化方法:实现“一次部署,处处运行”

Python 自动化识别Nginx配置并导出为excel文件,提升Nginx管理效率

Python 5个常见的异步任务处理框架

Python数据科学常见的30个库

Python 50个实用代码片段,优雅高效


1. 海象运算符(Python 3.8+)

Python 3.8 引入的 := 可以在表达式里直接赋值,省掉一次单独的赋值语句:

# 传统写法lines = []whileTrue:line = input()ifnotline:breaklines.append(line)# 使用海象运算符lines = []while (line := input()):lines.append(line)

2. 类型提示

类型提示不影响运行,但 IDE 的补全和 mypy 的静态检查都依赖它。写库或者多人协作时特别省事:

fromtypingimportOptionalListTupledefprocess_data(dataList[int],thresholdOptional[int] = None->Tuple[List[int], int]:"""处理数据并返回结果和计数"""ifthresholdisNone:threshold = 0filtered = [xforxindataifx>threshold]returnfilteredlen(filtered)

3. pathlib 处理文件路径

用字符串拼路径是老写法,pathlib 更直观,也跨平台:

frompathlibimportPathdata_dir = Path("data")data_dir.mkdir(exist_ok=True)file_path = data_dir/"output.txt"file_path.write_text("Hello, Python!")content = file_path.read_text()print(content)

4. 字典 get 方法设置默认值

访问字典里不存在的键会直接抛 KeyError,用 get 可以给个默认值兜底:

user_preferences = {"theme""dark""language""zh"}theme = user_preferences.get("theme""light")font_size = user_preferences.get("font_size"14)  # 返回默认值 14

5. collections.defaultdict

需要给字典里每个新键自动初始化一个默认值时,defaultdict 比手动判断 if key not in d 简洁很多:

fromcollectionsimportdefaultdicttext = "apple banana apple orange banana apple"word_count = defaultdict(int)forwordintext.split():word_count[word] += 1print(dict(word_count))  # {'apple': 3, 'banana': 2, 'orange': 1}

6. enumerate 获取索引和值

遍历时需要索引,不用 range(len(...)),直接用 enumerate

fruits = ["apple""banana""orange""grape"]forifruitinenumerate(fruitsstart=1):  # 从 1 开始计数print(f"{i}. {fruit}")

7. zip 并行遍历多个序列

多个列表要一起遍历,用 zip 比手动管索引清楚:

names = ["Alice""Bob""Charlie"]scores = [859278]subjects = ["Math""Science""English"]fornamescoresubjectinzip(namesscoressubjects):print(f"{name} got {score} in {subject}")# 顺手转成字典result = dict(zip(namesscores))print(result)  # {'Alice': 85, 'Bob': 92, 'Charlie': 78}

8. 嵌套列表推导式

列表推导式可以嵌套,生成二维结构时比双层 for 循环紧凑:

multiplication_table = [[i*jforjinrange(16)] foriinrange(16)]forrowinmultiplication_table:print(row)# [1, 2, 3, 4, 5]# [2, 4, 6, 8, 10]# ...

9. any() 和 all()

判断序列里是否有满足条件的元素,或者全部满足:

numbers = [246810]all_even = all(n%2 == 0forninnumbers)print(f"All even: {all_even}")  # Truehas_large = any(n>5forninnumbers)print(f"Has number > 5: {has_large}")  # True

10. sorted 多条件排序

sorted 的 key 参数接收 lambda,可以同时按多个字段排序

students = [    {"name""Alice""score"85"age"20},    {"name""Bob""score"92"age"19},    {"name""Charlie""score"85"age"21},    {"name""David""score"78"age"20},]# 分数降序,年龄升序sorted_students = sorted(students,key=lambdax: (-x["score"], x["age"]))forstudentinsorted_students:print(f"{student['name']}: score={student['score']}, age={student['age']}")

11. f-string 格式化

f-string 的格式化能力比很多人用到的强得多:

name = "Python"version = 3.11price = 0.0print(f"Language: {name:>10}")      # 右对齐,宽度 10print(f"Version: {version:.2f}")    # 保留 2 位小数print(f"Price: ${price:,.2f}")      # 千位分隔符print(f"Hex: {255:#06x}")           # 十六进制,宽度 6,前导 0print(f"Binary: {42:08b}")          # 二进制,宽度 8,前导 0

12. itertools 处理迭代器

标准库里的 itertools 提供了不少实用的迭代工具,排列组合、无限计数都有:

importitertoolscounter = itertools.count(start=10step=2)print(next(counter))  # 10print(next(counter))  # 12print(next(counter))  # 14letters = ['A''B''C']combinations = list(itertools.combinations(letters2))print(combinations)  # [('A', 'B'), ('A', 'C'), ('B', 'C')]permutations = list(itertools.permutations(letters2))print(permutations)  # [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]

13. contextlib 创建上下文管理器

用 @contextmanager 装饰器可以把普通函数变成上下文管理器,不需要写 __enter__/__exit__

fromcontextlibimportcontextmanagerimporttime@contextmanagerdeftimer(labelstr):start = time.time()try:yieldfinally:end = time.time()print(f"{label}: {end - start:.4f} seconds")withtimer("Calculation"):result = sum(i**2foriinrange(1000000))print(f"Result: {result}")

14. dataclasses 简化类定义

主要用来存数据的类,用 @dataclass 比手写 __init__/__repr__/__eq__ 省很多:

fromdataclassesimportdataclassfieldfromtypingimportListfromdatetimeimportdatetime@dataclass(order=True)classProduct:namestrpricefloatcategorystr = "General"tagsList[str] = field(default_factory=list)created_atdatetime = field(default_factory=datetime.now)defdisplay_price(self->str:returnf"${self.price:.2f}"product1 = Product("Laptop"999.99"Electronics", ["tech""portable"])product2 = Product("Book"29.99"Education")print(product1)print(f"Formatted price: {product1.display_price()}")print(f"product1 > product2: {product1 > product2}")

15. partial 固定函数参数

functools.partial 可以预先固定函数的某些参数,生成一个新的可调用对象

fromfunctoolsimportpartialdefpower(basefloatexponentfloat->float:returnbase**exponentsquare = partial(powerexponent=2)cube = partial(powerexponent=3)print(f"Square of 5: {square(5)}")    # 25.0print(f"Cube of 3: {cube(3)}")        # 27.0

16. lru_cache 缓存函数结果

对于重复计算成本高的函数,加一个 @lru_cache 就能自动缓存结果:

fromfunctoolsimportlru_cacheimporttime@lru_cache(maxsize=128)deffibonacci(nint->int:ifn<2:returnnreturnfibonacci(n-1+fibonacci(n-2)start = time.time()result = fibonacci(35)print(f"fibonacci(35) = {result}")print(f"Time taken: {time.time() - start:.4f} seconds")start = time.time()result = fibonacci(35)print(f"Cached call time: {time.time() - start:.6f} seconds")

17. NamedTuple 创建轻量级对象

比普通元组多字段名,比 dataclass 更轻量,适合只读数据结构:

fromtypingimportNamedTupleclassPoint3D(NamedTuple):xfloatyfloatzfloatdefdistance_from_origin(self->float:return (self.x**2+self.y**2+self.z**2**0.5p1 = Point3D(1.02.03.0)p2 = Point3D(4.05.06.0)print(f"Point 1: {p1}")print(f"Distance from origin: {p1.distance_from_origin():.2f}")print(f"Points are equal: {p1 == p2}")

18. ChainMap 合并多个字典

有多层配置(默认值、用户配置、环境变量)时,ChainMap 比手动合并字典更清晰,优先级也更好控制:

fromcollectionsimportChainMapdefault_config = {"theme""light""language""en""debug"False}user_config = {"theme""dark""font_size"14}env_config = {"debug"True}# 优先级:env_config > user_config > default_configconfig = ChainMap(env_configuser_configdefault_config)print(f"Theme: {config['theme']}")       # 来自 user_configprint(f"Language: {config['language']}"# 来自 default_configprint(f"Debug: {config['debug']}")       # 来自 env_config

19. 海象运算符配合正则

:= 在 for 循环里结合 re.match 特别好用,省掉了先 match 再判断 if match 的步骤:

importrelines = ["Error: File not found","Warning: Low disk space","Info: Process started","Error: Permission denied",]errors = []forlineinlines:ifmatch := re.match(r"Error: (.+)"line):errors.append(match.group(1))print(f"Errors found: {errors}")# 列表推导式里也能用data = [12345]processed = [n_squaredforxindataif (n_squared := x**2>10]print(f"Squares > 10: {processed}")

20. 解包操作符

Python 3.5+ 的扩展解包,合并列表、字典都很方便:

first*middlelast = [12345]print(f"First: {first}, Middle: {middle}, Last: {last}")# 合并字典(Python 3.9+)dict1 = {"a"1"b"2}dict2 = {"b"3"c"4}merged = dict1|dict2print(f"Merged dict: {merged}")# 函数参数解包defconnect(hostporttimeout=30):print(f"Connecting to {host}:{port} (timeout: {timeout})")server_config = {"host""example.com""port"8080"timeout"60}connect(**server_config)# 合并列表list1 = [123]list2 = [456]combined = [*list1*list2]print(f"Combined list: {combined}")

21.__slots__ 减少内存占用

需要创建大量实例的类,加 __slots__ 可以显著减少每个实例的内存开销:

classPlayer:__slots__ = ('name''score''level')def__init__(selfnamestrscoreint = 0levelint = 1):self.name = nameself.score = scoreself.level = leveldeflevel_up(self):self.level += 1self.score += 100players = [Player(f"Player{i}"i*100i//10+1foriinrange(1000)]importsysplayer_instance = Player("Test")print(f"Memory size of Player instance: {sys.getsizeof(player_instance)} bytes")

22. property 装饰器

用 @property 可以把方法包装成属性访问,在赋值时加验证逻辑也很自然:

classCircle:def__init__(selfradiusfloat):self._radius = radius@propertydefradius(self->float:returnself._radius@radius.setterdefradius(selfvaluefloat):ifvalue<0:raiseValueError("Radius must be positive")self._radius = value@propertydefdiameter(self->float:return2*self._radius@diameter.setterdefdiameter(selfvaluefloat):self._radius = value/2@propertydefarea(self->float:return3.14159*self._radius**2circle = Circle(5.0)print(f"Radius: {circle.radius}")print(f"Area: {circle.area:.2f}")circle.diameter = 20.0print(f"New radius after setting diameter: {circle.radius}")

23. classmethod 和 staticmethod

@staticmethod 不依赖实例或类,纯粹是挂在类名下的工具函数;@classmethod 拿到的是类本身,常用作替代构造函数:

classTemperatureConverter:@staticmethoddefcelsius_to_fahrenheit(celsiusfloat->float:returncelsius*9/5+32@staticmethoddeffahrenheit_to_celsius(fahrenheitfloat->float:return (fahrenheit-32*5/9@classmethoddeffrom_string(clstemp_strstr):valueunit = temp_str.split()value = float(value)ifunit.upper() == 'C':returncls(value'C')elifunit.upper() == 'F':celsius = cls.fahrenheit_to_celsius(value)returncls(celsius'C')else:raiseValueError(f"Unknown unit: {unit}")def__init__(selfvaluefloatunitstr = 'C'):self.celsius = valueifunit.upper() == 'C'elseself.fahrenheit_to_celsius(value)@propertydeffahrenheit(self->float:returnself.celsius_to_fahrenheit(self.celsius)def__str__(self):returnf"{self.celsius:.1f}°C ({self.fahrenheit:.1f}°F)"print(f"37°C in Fahrenheit: {TemperatureConverter.celsius_to_fahrenheit(37):.1f}")temp1 = TemperatureConverter(25'C')print(f"Temperature 1: {temp1}")temp2 = TemperatureConverter.from_string("98.6 F")print(f"Temperature 2: {temp2}")

24. 抽象基类(abc)

用 ABC 定义接口,强制子类实现指定方法,防止漏掉:

fromabcimportABCabstractmethodfromtypingimportListclassDataProcessor(ABC):@abstractmethoddefload_data(selfsourcestr->List[dict]:pass@abstractmethoddefprocess(selfdataList[dict]) ->List[dict]:pass@abstractmethoddefsave_result(selfdataList[dict], destinationstr->bool:passdefrun_pipeline(selfsourcestrdestinationstr->bool:try:data = self.load_data(source)processed_data = self.process(data)returnself.save_result(processed_datadestination)exceptExceptionase:print(f"Pipeline failed: {e}")returnFalseclassCSVProcessor(DataProcessor):defload_data(selfsourcestr->List[dict]:print(f"Loading CSV data from {source}")return [{"id"1"name""Alice"}, {"id"2"name""Bob"}]defprocess(selfdataList[dict]) ->List[dict]:importdatetimeforitemindata:item["processed_at"] = datetime.datetime.now().isoformat()returndatadefsave_result(selfdataList[dict], destinationstr->bool:print(f"Saving processed data to {destination}")returnTrueprocessor = CSVProcessor()success = processor.run_pipeline("input.csv""output.csv")print(f"Pipeline completed: {success}")

25. async/await 异步编程

I/O 密集型任务(比如同时请求多个接口)用异步可以大幅提升吞吐:

importasyncioimportaiohttpimporttimefromtypingimportListasyncdeffetch_url(sessionaiohttp.ClientSessionurlstr->str:asyncwithsession.get(urlasresponse:returnawaitresponse.text()asyncdeffetch_multiple_urls(urlsList[str]):asyncwithaiohttp.ClientSession() assession:tasks = [fetch_url(sessionurlforurlinurls]results = awaitasyncio.gather(*tasksreturn_exceptions=True)returnresultsasyncdefmain():urls = ["https://httpbin.org/delay/1","https://httpbin.org/delay/2","https://httpbin.org/delay/1",    ]start_time = time.time()results = awaitfetch_multiple_urls(urls)print(f"Fetched {len(urls)} URLs in {time.time() - start_time:.2f} seconds")foriresultinenumerate(results):ifisinstance(resultException):print(f"URL {i+1} failed: {result}")else:print(f"URL {i+1} response length: {len(result)}")# asyncio.run(main())print("Note: Async code requires asyncio.run() to execute")

26. 描述符控制属性访问

描述符可以把验证逻辑抽出来复用,不用在每个属性的 setter 里重复写:

classValidatedAttribute:def__init__(selfmin_value=Nonemax_value=Noneallowed_values=None):self.min_value = min_valueself.max_value = max_valueself.allowed_values = allowed_valuesself.name = Nonedef__set_name__(selfownername):self.name = namedef__get__(selfobjobjtype=None):ifobjisNone:returnselfreturnobj.__dict__.get(self.name)def__set__(selfobjvalue):self._validate(value)obj.__dict__[self.name] = valuedef_validate(selfvalue):ifself.min_valueisnotNoneandvalue<self.min_value:raiseValueError(f"{self.name} must be >= {self.min_value}")ifself.max_valueisnotNoneandvalue>self.max_value:raiseValueError(f"{self.name} must be <= {self.max_value}")ifself.allowed_valuesisnotNoneandvaluenotinself.allowed_values:raiseValueError(f"{self.name} must be one of {self.allowed_values}")classProduct:price = ValidatedAttribute(min_value=0)quantity = ValidatedAttribute(min_value=0max_value=1000)category = ValidatedAttribute(allowed_values=["Electronics""Books""Clothing"])def__init__(selfnamestrpricefloatquantityintcategorystr):self.name = nameself.price = priceself.quantity = quantityself.category = category@propertydeftotal_value(self->float:returnself.price*self.quantitytry:laptop = Product("Laptop"999.9910"Electronics")print(f"Total value: ${laptop.total_value:.2f}")laptop.price = -100# 触发 ValueErrorexceptValueErrorase:print(f"Validation error: {e}")try:invalid_product = Product("Test"502000"Unknown")exceptValueErrorase:print(f"Validation error: {e}")

27. 元类实现单例

元类是 Python 里比较深的特性,最常见的实际用途之一是实现单例:

classSingletonMeta(type):_instances = {}def__call__(cls*args**kwargs):ifclsnotincls._instances:cls._instances[cls] = super().__call__(*args**kwargs)returncls._instances[cls]classDatabaseConnection(metaclass=SingletonMeta):def__init__(selfconnection_stringstr):self.connection_string = connection_stringself._connected = Falseprint(f"Initializing connection to {connection_string}")defconnect(self):ifnotself._connected:print("Establishing connection...")self._connected = Truereturnself._connecteddefexecute_query(selfquerystr):ifnotself._connected:raiseRuntimeError("Not connected to database")returnf"Result of: {query}"db1 = DatabaseConnection("mysql://localhost:3306/mydb")db1.connect()db2 = DatabaseConnection("mysql://localhost:3306/mydb")  # 不会重新初始化print(f"db1 is db2: {db1 is db2}")  # Trueprint(db1.execute_query("SELECT * FROM users"))print(db2.execute_query("SELECT * FROM products"))

28. 装饰器:retry + timer

装饰器可以叠加使用,下面是两个实用的例子——计时和自动重试:

importtimeimportfunctoolsfromtypingimportCallableAnydefretry(max_attemptsint = 3delayfloat = 1.0):defdecorator(funcCallable->Callable:@functools.wraps(func)defwrapper(*args**kwargs->Any:last_exception = Noneforattemptinrange(1max_attempts+1):try:print(f"Attempt {attempt}/{max_attempts}...")returnfunc(*args**kwargs)exceptExceptionase:last_exception = eifattempt<max_attempts:print(f"Failed: {e}. Retrying in {delay}s...")time.sleep(delay)raiselast_exceptionreturnwrapperreturndecoratordeftimer(funcCallable->Callable:@functools.wraps(func)defwrapper(*args**kwargs->Any:start_time = time.time()result = func(*args**kwargs)print(f"{func.__name__} took {time.time() - start_time:.4f} seconds")returnresultreturnwrapper@timer@retry(max_attempts=2delay=0.5)defunstable_operation(should_failbool = True):ifshould_fail:raiseRuntimeError("Operation failed!")return"Success"try:result = unstable_operation(should_fail=True)exceptExceptionase:print(f"Operation failed with: {e}")

29. warnings 模块

标记废弃 API 或者给用户提示非致命问题,用 warnings 比直接 print 更规范——调用方可以选择过滤或捕获:

importwarningsimportdatetimedefprocess_data(datause_old_method=False):ifuse_old_method:warnings.warn("Old method is deprecated and will be removed in v2.0. ""Use the default method instead.",DeprecationWarning,stacklevel=2        )returnf"Old result: {len(data)}"returnf"New result: {sum(data)}"defcheck_expiry(expiry_date):today = datetime.date.today()ifexpiry_date<today:warnings.warn(f"Product expired on {expiry_date}"UserWarning)returnFalseelif (expiry_date-today).days<7:warnings.warn(f"Product will expire in {(expiry_date - today).days} days",UserWarning        )returnTruewarnings.simplefilter("always")result1 = process_data([123], use_old_method=True)print(f"Result: {result1}")today = datetime.date.today()check_expiry(today-datetime.timedelta(days=30))check_expiry(today+datetime.timedelta(days=3))check_expiry(today+datetime.timedelta(days=100))# 忽略 DeprecationWarningwarnings.simplefilter("ignore"category=DeprecationWarning)result2 = process_data([123], use_old_method=True)print(f"Result (no warning): {result2}")

30. logging 替代 print

调试阶段用 print 没问题,但正式项目里 logging 能分级别、写文件、按大小轮转,维护起来方便得多:

importloggingimportlogging.handlersfrompathlibimportPathdefsetup_logging(namestr,log_filestr = "app.log",console_level=logging.INFO,file_level=logging.DEBUG):log_path = Path(log_file)log_path.parent.mkdir(parents=Trueexist_ok=True)logger = logging.getLogger(name)logger.setLevel(logging.DEBUG)iflogger.handlers:returnloggerformatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s'    )console_handler = logging.StreamHandler()console_handler.setLevel(console_level)console_handler.setFormatter(formatter)logger.addHandler(console_handler)file_handler = logging.handlers.RotatingFileHandler(log_filemaxBytes=10*1024*1024backupCount=5    )file_handler.setLevel(file_level)file_handler.setFormatter(formatter)logger.addHandler(file_handler)returnloggerclassDataProcessor:def__init__(selfnamestr):self.logger = setup_logging(f"DataProcessor.{name}")self.name = nameself.logger.info(f"DataProcessor '{name}' initialized")defprocess(selfdata):self.logger.debug(f"Starting to process {len(data)} items")ifnotdata:self.logger.warning("Empty data provided")return []try:result = []foriiteminenumerate(data):processed = self._transform(item)result.append(processed)if (i+1%10 == 0:self.logger.info(f"Processed {i + 1}/{len(data)} items")self.logger.info(f"Successfully processed {len(data)} items")returnresultexceptExceptionase:self.logger.error(f"Error processing data: {e}"exc_info=True)raisedef_transform(selfitem):ifnotisinstance(item, (intfloat)):self.logger.warning(f"Unexpected type: {type(item)}")ifitem == 0:self.logger.error("Cannot process zero value")raiseValueError("Zero value not allowed")returnitem*2processor = DataProcessor("TestProcessor")test_data = list(range(125))test_data.append(0)try:result = processor.process(test_data)print(f"Result length: {len(result)}")exceptExceptionase:print(f"Processing failed: {e}")logger = setup_logging("Demo")logger.debug("debug message")logger.info("info message")logger.warning("warning message")logger.error("error message")logger.critical("critical message")

以上 30 条覆盖了日常开发里比较常踩到的点。随时能用上在写库或者需要长期维护的项目里更有价值。不需要全部记住,遇到对应场景时翻出来用就行。

“无他,惟手熟尔”!有需要的用起来!
如果你觉得这篇文章有用,欢迎点赞、转发、收藏、留言、推荐

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-07-03 15:21:11 HTTP/2.0 GET : https://f.mffb.com.cn/a/486979.html
  2. 运行时间 : 0.608503s [ 吞吐率:1.64req/s ] 内存消耗:4,828.71kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=00b6973eb5df7bdbb540ea60edb7f251
  1. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/public/index.php ( 0.79 KB )
  2. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/autoload.php ( 0.17 KB )
  3. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_real.php ( 2.49 KB )
  4. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/platform_check.php ( 0.90 KB )
  5. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/ClassLoader.php ( 14.03 KB )
  6. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/composer/autoload_static.php ( 4.90 KB )
  7. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper.php ( 8.34 KB )
  8. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/helper.php ( 2.19 KB )
  9. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/helper.php ( 1.47 KB )
  10. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/stubs/load_stubs.php ( 0.16 KB )
  11. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Exception.php ( 1.69 KB )
  12. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Facade.php ( 2.71 KB )
  13. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/deprecation-contracts/function.php ( 0.99 KB )
  14. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap.php ( 8.26 KB )
  15. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/polyfill-mbstring/bootstrap80.php ( 9.78 KB )
  16. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/Resources/functions/dump.php ( 1.49 KB )
  17. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-dumper/src/helper.php ( 0.18 KB )
  18. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/symfony/var-dumper/VarDumper.php ( 4.30 KB )
  19. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/App.php ( 15.30 KB )
  20. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-container/src/Container.php ( 15.76 KB )
  21. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/container/src/ContainerInterface.php ( 1.02 KB )
  22. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/provider.php ( 0.19 KB )
  23. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Http.php ( 6.04 KB )
  24. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Str.php ( 7.29 KB )
  25. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Env.php ( 4.68 KB )
  26. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/common.php ( 0.03 KB )
  27. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/helper.php ( 18.78 KB )
  28. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Config.php ( 5.54 KB )
  29. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/app.php ( 0.95 KB )
  30. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cache.php ( 0.78 KB )
  31. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/console.php ( 0.23 KB )
  32. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/cookie.php ( 0.56 KB )
  33. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/database.php ( 2.48 KB )
  34. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Env.php ( 1.67 KB )
  35. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/filesystem.php ( 0.61 KB )
  36. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/lang.php ( 0.91 KB )
  37. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/log.php ( 1.35 KB )
  38. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/middleware.php ( 0.19 KB )
  39. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/route.php ( 1.89 KB )
  40. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/session.php ( 0.57 KB )
  41. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/trace.php ( 0.34 KB )
  42. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/config/view.php ( 0.82 KB )
  43. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/event.php ( 0.25 KB )
  44. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Event.php ( 7.67 KB )
  45. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/service.php ( 0.13 KB )
  46. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/AppService.php ( 0.26 KB )
  47. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Service.php ( 1.64 KB )
  48. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Lang.php ( 7.35 KB )
  49. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/lang/zh-cn.php ( 13.70 KB )
  50. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/Error.php ( 3.31 KB )
  51. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/RegisterService.php ( 1.33 KB )
  52. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/services.php ( 0.14 KB )
  53. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/PaginatorService.php ( 1.52 KB )
  54. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ValidateService.php ( 0.99 KB )
  55. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/service/ModelService.php ( 2.04 KB )
  56. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Service.php ( 0.77 KB )
  57. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Middleware.php ( 6.72 KB )
  58. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/initializer/BootService.php ( 0.77 KB )
  59. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Paginator.php ( 11.86 KB )
  60. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-validate/src/Validate.php ( 63.20 KB )
  61. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/Model.php ( 23.55 KB )
  62. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Attribute.php ( 21.05 KB )
  63. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/AutoWriteData.php ( 4.21 KB )
  64. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/Conversion.php ( 6.44 KB )
  65. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/DbConnect.php ( 5.16 KB )
  66. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/ModelEvent.php ( 2.33 KB )
  67. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/concern/RelationShip.php ( 28.29 KB )
  68. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Arrayable.php ( 0.09 KB )
  69. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/contract/Jsonable.php ( 0.13 KB )
  70. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/model/contract/Modelable.php ( 0.09 KB )
  71. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Db.php ( 2.88 KB )
  72. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/DbManager.php ( 8.52 KB )
  73. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Log.php ( 6.28 KB )
  74. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Manager.php ( 3.92 KB )
  75. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerTrait.php ( 2.69 KB )
  76. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/log/src/LoggerInterface.php ( 2.71 KB )
  77. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cache.php ( 4.92 KB )
  78. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/psr/simple-cache/src/CacheInterface.php ( 4.71 KB )
  79. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/helper/Arr.php ( 16.63 KB )
  80. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/driver/File.php ( 7.84 KB )
  81. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/cache/Driver.php ( 9.03 KB )
  82. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/CacheHandlerInterface.php ( 1.99 KB )
  83. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/Request.php ( 0.09 KB )
  84. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Request.php ( 55.78 KB )
  85. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/middleware.php ( 0.25 KB )
  86. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Pipeline.php ( 2.61 KB )
  87. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/TraceDebug.php ( 3.40 KB )
  88. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/middleware/SessionInit.php ( 1.94 KB )
  89. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Session.php ( 1.80 KB )
  90. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/driver/File.php ( 6.27 KB )
  91. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/SessionHandlerInterface.php ( 0.87 KB )
  92. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/session/Store.php ( 7.12 KB )
  93. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Route.php ( 23.73 KB )
  94. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleName.php ( 5.75 KB )
  95. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Domain.php ( 2.53 KB )
  96. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleGroup.php ( 22.43 KB )
  97. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Rule.php ( 26.95 KB )
  98. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/RuleItem.php ( 9.78 KB )
  99. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/route/app.php ( 1.72 KB )
  100. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/Route.php ( 4.70 KB )
  101. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/dispatch/Controller.php ( 4.74 KB )
  102. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/route/Dispatch.php ( 10.44 KB )
  103. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/controller/Index.php ( 4.81 KB )
  104. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/app/BaseController.php ( 2.05 KB )
  105. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/facade/Db.php ( 0.93 KB )
  106. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/connector/Mysql.php ( 5.44 KB )
  107. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/PDOConnection.php ( 52.47 KB )
  108. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Connection.php ( 8.39 KB )
  109. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/ConnectionInterface.php ( 4.57 KB )
  110. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/builder/Mysql.php ( 16.58 KB )
  111. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Builder.php ( 24.06 KB )
  112. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseBuilder.php ( 27.50 KB )
  113. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/Query.php ( 15.71 KB )
  114. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/BaseQuery.php ( 45.13 KB )
  115. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TimeFieldQuery.php ( 7.43 KB )
  116. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/AggregateQuery.php ( 3.26 KB )
  117. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ModelRelationQuery.php ( 20.07 KB )
  118. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ParamsBind.php ( 3.66 KB )
  119. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/ResultOperation.php ( 7.01 KB )
  120. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/WhereQuery.php ( 19.37 KB )
  121. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/JoinAndViewQuery.php ( 7.11 KB )
  122. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/TableFieldInfo.php ( 2.63 KB )
  123. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-orm/src/db/concern/Transaction.php ( 2.77 KB )
  124. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/driver/File.php ( 5.96 KB )
  125. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/LogHandlerInterface.php ( 0.86 KB )
  126. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/log/Channel.php ( 3.89 KB )
  127. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/event/LogRecord.php ( 1.02 KB )
  128. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-helper/src/Collection.php ( 16.47 KB )
  129. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/facade/View.php ( 1.70 KB )
  130. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/View.php ( 4.39 KB )
  131. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Response.php ( 8.81 KB )
  132. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/response/View.php ( 3.29 KB )
  133. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/Cookie.php ( 6.06 KB )
  134. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-view/src/Think.php ( 8.38 KB )
  135. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/framework/src/think/contract/TemplateHandlerInterface.php ( 1.60 KB )
  136. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/Template.php ( 46.61 KB )
  137. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/driver/File.php ( 2.41 KB )
  138. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-template/src/template/contract/DriverInterface.php ( 0.86 KB )
  139. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/runtime/temp/067d451b9a0c665040f3f1bdd3293d68.php ( 11.98 KB )
  140. /yingpanguazai/ssd/ssd1/www/f.mffb.com.cn/vendor/topthink/think-trace/src/Html.php ( 4.42 KB )
  1. CONNECT:[ UseTime:0.000672s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000737s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.017846s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.001037s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000764s ]
  6. SELECT * FROM `set` [ RunTime:0.079797s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000922s ]
  8. SELECT * FROM `article` WHERE `id` = 486979 LIMIT 1 [ RunTime:0.099102s ]
  9. UPDATE `article` SET `lasttime` = 1783063272 WHERE `id` = 486979 [ RunTime:0.093865s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.011907s ]
  11. SELECT * FROM `article` WHERE `id` < 486979 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.001509s ]
  12. SELECT * FROM `article` WHERE `id` > 486979 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.020768s ]
  13. SELECT * FROM `article` WHERE `id` < 486979 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.027487s ]
  14. SELECT * FROM `article` WHERE `id` < 486979 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000864s ]
  15. SELECT * FROM `article` WHERE `id` < 486979 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.176590s ]
0.610101s