当前位置:首页>python>50个Python实用代码案例:拿来即用,效率翻倍!

50个Python实用代码案例:拿来即用,效率翻倍!

  • 2026-01-12 22:58:28
50个Python实用代码案例:拿来即用,效率翻倍!

关注+星标,每天学习Python新技能

来源:网络

Python作为一门简洁而强大的编程语言,已经渗透到我们生活的方方面面。无论您是数据分析师、Web开发者,还是仅仅对编程感兴趣,Python都能为您提供强大的支持。本文汇集了50个精心挑选的Python代码小案例,它们涵盖了文件处理、数据操作、网络请求、日期时间处理、以及实用工具等多个方面。

文章结构概览:

为了方便您查找和学习,我们将这50个案例大致分为以下几个类别:

  • 文件与目录操作 (案例 1-10)
  • 数据处理与分析 (案例 11-20)
  • 网络请求与Web (案例 21-30)
  • 日期与时间处理 (案例 31-40)
  • 实用工具与技巧 (案例 41-50)

1. 文件与目录操作

文件和目录操作是编程的基础,Python提供了强大的库来处理这些任务。

案例1:  读取文件内容

defread_file_content(filepath):"""读取文件内容并返回字符串."""try:with open(filepath, 'r', encoding='utf-8'as f:            content = f.read()return contentexcept FileNotFoundError:return"文件未找到"# 示例file_content = read_file_content('example.txt')print(file_content)

案例2:  逐行读取文件内容

defread_file_line_by_line(filepath):"""逐行读取文件内容并返回列表."""try:with open(filepath, 'r', encoding='utf-8'as f:            lines = f.readlines()return linesexcept FileNotFoundError:return ["文件未找到"]# 示例lines = read_file_line_by_line('example.txt')for line in lines:    print(line.strip()) # strip()去除行尾的换行符

案例3:  写入内容到文件

defwrite_content_to_file(filepath, content):"""将内容写入文件."""try:with open(filepath, 'w', encoding='utf-8'as f:            f.write(content)return"写入成功"except Exception as e:returnf"写入失败: {e}"# 示例write_result = write_content_to_file('output.txt''这是要写入的内容。\n第二行内容。')print(write_result)

案例4:  追加内容到文件

defappend_content_to_file(filepath, content):"""将内容追加到文件末尾."""try:with open(filepath, 'a', encoding='utf-8'as f:            f.write(content)return"追加成功"except Exception as e:returnf"追加失败: {e}"# 示例append_result = append_content_to_file('output.txt''\n这是追加的内容。')print(append_result)

案例5:  检查文件是否存在

import osdefcheck_file_exists(filepath):"""检查文件是否存在."""return os.path.exists(filepath)# 示例exists = check_file_exists('example.txt')print(f"文件是否存在: {exists}")

案例6:  创建目录

import osdefcreate_directory(dirpath):"""创建目录."""try:        os.makedirs(dirpath, exist_ok=True# exist_ok=True 表示目录已存在时不会报错returnf"目录 '{dirpath}' 创建成功"except Exception as e:returnf"目录创建失败: {e}"# 示例create_result = create_directory('new_directory')print(create_result)

案例7:  删除文件

import osdefdelete_file(filepath):"""删除文件."""try:        os.remove(filepath)returnf"文件 '{filepath}' 删除成功"except FileNotFoundError:return"文件未找到"except Exception as e:returnf"文件删除失败: {e}"# 示例delete_result = delete_file('output.txt')print(delete_result)

案例8:  删除目录 (目录必须为空)

import osdefdelete_directory(dirpath):"""删除目录 (目录必须为空)."""try:        os.rmdir(dirpath)returnf"目录 '{dirpath}' 删除成功"except FileNotFoundError:return"目录未找到"except OSError:return"目录非空,无法删除"except Exception as e:returnf"目录删除失败: {e}"# 示例delete_result = delete_directory('new_directory')print(delete_result) # 如果目录不为空,会打印 "目录非空,无法删除"

案例9:  列出目录中的文件和子目录

import osdeflist_directory_contents(dirpath):"""列出目录中的文件和子目录."""try:        contents = os.listdir(dirpath)return contentsexcept FileNotFoundError:return ["目录未找到"]# 示例directory_contents = list_directory_contents('.'# '.' 表示当前目录print(f"目录内容: {directory_contents}")

案例10:  获取文件大小

import osdefget_file_size(filepath):"""获取文件大小,单位为字节."""try:        size_in_bytes = os.path.getsize(filepath)return size_in_bytesexcept FileNotFoundError:return"文件未找到"# 示例file_size = get_file_size('example.txt')print(f"文件大小: {file_size} 字节")

2. 数据处理与分析

Python在数据处理领域拥有强大的库,如 collections 和 itertools, 以及流行的 pandas 和 numpy (虽然这里我们主要关注Python标准库)。

案例11:  统计列表中元素出现的次数

from collections import Counterdefcount_list_items(data_list):"""统计列表中每个元素出现的次数,返回字典."""return Counter(data_list)# 示例my_list = ['a''b''a''c''b''b']counts = count_list_items(my_list)print(f"元素计数: {counts}"# Counter({'b': 3, 'a': 2, 'c': 1})

案例12:  去除列表中的重复元素

defremove_duplicates_from_list(data_list):"""去除列表中的重复元素,保持顺序."""return list(dict.fromkeys(data_list)) # 利用字典的键唯一性# 示例my_list = [12234451]unique_list = remove_duplicates_from_list(my_list)print(f"去重后的列表: {unique_list}"# [1, 2, 3, 4, 5]

案例13:  合并两个字典

defmerge_dictionaries(dict1, dict2):"""合并两个字典,如果键冲突,dict2 的值覆盖 dict1 的."""    merged_dict = dict1.copy() # 创建 dict1 的副本,避免修改原字典    merged_dict.update(dict2) # 将 dict2 的键值对添加到 merged_dictreturn merged_dict# 示例dict1 = {'a'1'b'2}dict2 = {'b'3'c'4}merged = merge_dictionaries(dict1, dict2)print(f"合并后的字典: {merged}"# {'a': 1, 'b': 3, 'c': 4}

案例14:  反转字典的键值对

defreverse_dictionary(data_dict):"""反转字典的键值对."""return {v: k for k, v in data_dict.items()}# 示例my_dict = {'name''Alice''age'30}reversed_dict = reverse_dictionary(my_dict)print(f"反转后的字典: {reversed_dict}"# {'Alice': 'name', 30: 'age'}

案例15:  字典按值排序

defsort_dictionary_by_value(data_dict, reverse=False):"""按字典的值排序,返回排序后的键值对列表."""return sorted(data_dict.items(), key=lambda item: item[1], reverse=reverse)# 示例my_dict = {'a'10'c'1'b'5}sorted_dict = sort_dictionary_by_value(my_dict)print(f"按值升序排序: {sorted_dict}"# [('c', 1), ('b', 5), ('a', 10)]sorted_dict_desc = sort_dictionary_by_value(my_dict, reverse=True)print(f"按值降序排序: {sorted_dict_desc}"# [('a', 10), ('b', 5), ('c', 1)]

案例16:  列表推导式:快速生成列表

defgenerate_squares(n):"""使用列表推导式生成 0 到 n-1 的平方列表."""return [x**2for x in range(n)]# 示例squares = generate_squares(5)print(f"平方列表: {squares}"# [0, 1, 4, 9, 16]

案例17:  字典推导式:快速生成字典

defgenerate_dict_squares(n):"""使用字典推导式生成 0 到 n-1 的平方字典,键为数字,值为平方."""return {x: x**2for x in range(n)}# 示例dict_squares = generate_dict_squares(5)print(f"平方字典: {dict_squares}"# {0: 0, 1: 1, 2: 4, 3: 9, 4: 16}

案例18:  使用 zip 函数同时迭代多个列表

defcombine_lists(names, ages, cities):"""使用 zip 函数同时迭代三个列表,返回姓名、年龄和城市的组合列表."""    combined_list = []for name, age, city in zip(names, ages, cities):        combined_list.append(f"{name} is {age} years old and lives in {city}")return combined_list# 示例names = ['Alice''Bob''Charlie']ages = [253028]cities = ['New York''London''Paris']combined = combine_lists(names, ages, cities)for item in combined:    print(item)

案例19:  使用 enumerate 函数迭代列表并获取索引

deflist_with_index(data_list):"""使用 enumerate 函数迭代列表,返回元素和索引的组合列表."""    indexed_list = []for index, item in enumerate(data_list):        indexed_list.append(f"Index {index}{item}")return indexed_list# 示例my_list = ['apple''banana''cherry']indexed = list_with_index(my_list)for item in indexed:    print(item)

案例20:  使用 itertools.groupby 函数分组数据

import itertoolsdefgroup_by_key(data_list, key_func):"""使用 itertools.groupby 函数根据 key_func 分组数据."""    sorted_data = sorted(data_list, key=key_func) # groupby 前需要先排序    grouped_data = {}for key, group in itertools.groupby(sorted_data, key=key_func):        grouped_data[key] = list(group) # group 是迭代器,需要转换为 listreturn grouped_data# 示例data = [{'city''London''name''Alice'},        {'city''Paris''name''Bob'},        {'city''London''name''Charlie'},        {'city''Paris''name''David'}]grouped_by_city = group_by_key(data, key_func=lambda x: x['city'])print(f"按城市分组: {grouped_by_city}")

3. 网络请求与Web

Python的 requests 库让网络请求变得异常简单。

案例21:  发送GET请求并获取响应

import requestsdefget_webpage_content(url):"""发送 GET 请求到 URL 并返回网页内容."""try:        response = requests.get(url)        response.raise_for_status() # 检查请求是否成功 (状态码 200)return response.textexcept requests.exceptions.RequestException as e:returnf"请求失败: {e}"# 示例webpage_content = get_webpage_content('https://www.example.com')print(webpage_content[:200]) # 打印前 200 个字符

案例22:  发送POST请求并传递数据

import requestsimport jsondefpost_data_to_url(url, data):"""发送 POST 请求到 URL 并传递 JSON 数据."""try:        headers = {'Content-Type''application/json'}        response = requests.post(url, data=json.dumps(data), headers=headers)        response.raise_for_status()return response.json() # 尝试解析 JSON 响应except requests.exceptions.RequestException as e:returnf"请求失败: {e}"except json.JSONDecodeError:return"响应不是有效的 JSON 格式"# 示例post_url = 'https://httpbin.org/post'# 一个用于测试 HTTP 请求的网站post_data = {'name''John''age'30}post_response = post_data_to_url(post_url, post_data)print(f"POST 响应: {post_response}")

案例23:  下载文件到本地

import requestsdefdownload_file(url, filepath):"""从 URL 下载文件并保存到本地."""try:        response = requests.get(url, stream=True# stream=True 用于大文件下载        response.raise_for_status()with open(filepath, 'wb'as f:for chunk in response.iter_content(chunk_size=8192): # 分块写入,避免内存溢出                f.write(chunk)returnf"文件下载成功,保存到: {filepath}"except requests.exceptions.RequestException as e:returnf"文件下载失败: {e}"# 示例file_url = 'https://www.easygifanimator.net/images/samples/video-to-gif-sample.gif'# 一个 GIF 图片示例download_result = download_file(file_url, 'sample.gif')print(download_result)# [Image of sample gif image]

案例24:  获取网页的HTTP状态码

import requestsdefget_http_status_code(url):"""获取 URL 的 HTTP 状态码."""try:        response = requests.head(url) # 使用 HEAD 请求,只获取头部信息,更高效return response.status_codeexcept requests.exceptions.RequestException:return"请求失败"# 示例status_code = get_http_status_code('https://www.example.com')print(f"HTTP 状态码: {status_code}"# 通常为 200

案例25:  设置请求超时时间

import requestsdefget_webpage_with_timeout(url, timeout_seconds):"""发送 GET 请求,并设置超时时间."""try:        response = requests.get(url, timeout=timeout_seconds)        response.raise_for_status()return response.textexcept requests.exceptions.Timeout:return"请求超时"except requests.exceptions.RequestException as e:returnf"请求失败: {e}"# 示例content_with_timeout = get_webpage_with_timeout('https://www.example.com'5# 超时时间为 5 秒print(content_with_timeout[:200])

案例26:  添加请求头 (headers)

import requestsdefget_webpage_with_headers(url, headers):"""发送 GET 请求,并添加自定义请求头."""try:        response = requests.get(url, headers=headers)        response.raise_for_status()return response.textexcept requests.exceptions.RequestException as e:returnf"请求失败: {e}"# 示例custom_headers = {'User-Agent''My-Custom-User-Agent/1.0'}content_with_headers = get_webpage_with_headers('https://www.example.com', custom_headers)print(content_with_headers[:200])

案例27:  处理cookies

import requestsdefget_cookies_from_url(url):"""获取 URL 返回的 cookies."""try:        response = requests.get(url)return response.cookies.get_dict() # 将 Cookies 对象转换为字典except requests.exceptions.RequestException as e:returnf"请求失败: {e}"# 示例cookies = get_cookies_from_url("https://www.example.com")print(f"Cookies: {cookies}")

案例28:  发送带有Cookies的请求

import requestsdefget_webpage_with_cookies(url, cookies_dict):"""发送 GET 请求,并附带 cookies."""try:        response = requests.get(url, cookies=cookies_dict)        response.raise_for_status()return response.textexcept requests.exceptions.RequestException as e:returnf"请求失败: {e}"# 示例cookies_to_send = {'session_id''1234567890'# 假设的 cookiescontent_with_cookies = get_webpage_with_cookies('https://www.example.com', cookies_to_send)print(content_with_cookies[:200])

案例29:  简单的URL编码

import urllib.parsedefurl_encode_string(string_to_encode):"""对字符串进行 URL 编码."""return urllib.parse.quote(string_to_encode)# 示例encoded_string = url_encode_string("search query with spaces")print(f"URL 编码后的字符串: {encoded_string}"# search%20query%20with%20spaces

案例30:  简单的URL解码

import urllib.parsedefurl_decode_string(encoded_string):"""对 URL 编码的字符串进行解码."""return urllib.parse.unquote(encoded_string)# 示例decoded_string = url_decode_string("search%20query%20with%20spaces")print(f"URL 解码后的字符串: {decoded_string}"# search query with spaces

4. 日期与时间处理

Python的 datetime 模块提供了丰富的日期和时间处理功能。

案例31:  获取当前日期和时间

import datetimedefget_current_datetime():"""获取当前日期和时间,返回 datetime 对象."""return datetime.datetime.now()# 示例current_datetime = get_current_datetime()print(f"当前日期时间: {current_datetime}")

案例32:  格式化日期和时间

import datetimedefformat_datetime(datetime_obj, format_string="%Y-%m-%d %H:%M:%S"):"""将 datetime 对象格式化为字符串."""return datetime_obj.strftime(format_string)# 示例now = datetime.datetime.now()formatted_datetime = format_datetime(now)print(f"格式化后的日期时间: {formatted_datetime}"# 例如: 2023-10-27 10:30:45

案例33:  将字符串解析为日期时间对象

import datetimedefparse_datetime_string(datetime_string, format_string="%Y-%m-%d %H:%M:%S"):"""将字符串解析为 datetime 对象."""try:return datetime.datetime.strptime(datetime_string, format_string)except ValueError:return"日期时间字符串格式错误"# 示例date_string = "2023-10-27 10:30:00"parsed_datetime = parse_datetime_string(date_string)print(f"解析后的 datetime 对象: {parsed_datetime}")

案例34:  计算日期时间差

import datetimedefcalculate_datetime_difference(datetime1, datetime2):"""计算两个 datetime 对象的时间差,返回 timedelta 对象."""return datetime2 - datetime1# 示例datetime1 = datetime.datetime(20231026)datetime2 = datetime.datetime(20231027)time_difference = calculate_datetime_difference(datetime1, datetime2)print(f"时间差: {time_difference}"# 例如: 1 day, 0:00:00

案例35:  获取特定日期的年份、月份、日

import datetimedefget_date_components(datetime_obj):"""获取 datetime 对象的年份、月份、日."""return {'year': datetime_obj.year,'month': datetime_obj.month,'day': datetime_obj.day    }# 示例now = datetime.datetime.now()date_components = get_date_components(now)print(f"日期组件: {date_components}"# 例如: {'year': 2023, 'month': 10, 'day': 27}

案例36:  获取特定时间的小时、分钟、秒

import datetimedefget_time_components(datetime_obj):"""获取 datetime 对象的小时、分钟、秒."""return {'hour': datetime_obj.hour,'minute': datetime_obj.minute,'second': datetime_obj.second    }# 示例now = datetime.datetime.now()time_components = get_time_components(now)print(f"时间组件: {time_components}"# 例如: {'hour': 10, 'minute': 45, 'second': 30}

案例37:  获取当前时间戳 (秒)

import timedefget_current_timestamp():"""获取当前时间戳 (秒)."""return time.time()# 示例timestamp = get_current_timestamp()print(f"当前时间戳: {timestamp}"# 例如: 1698384000.0

案例38:  将时间戳转换为 datetime 对象

import datetimeimport timedeftimestamp_to_datetime(timestamp):"""将时间戳转换为 datetime 对象."""return datetime.datetime.fromtimestamp(timestamp)# 示例timestamp_value = time.time()datetime_from_timestamp = timestamp_to_datetime(timestamp_value)print(f"时间戳转换为 datetime 对象: {datetime_from_timestamp}")

案例39:  获取某个月的第一天和最后一天

import datetimeimport calendardefget_month_first_last_day(year, month):"""获取某年某月的第一天和最后一天."""    first_day = datetime.date(year, month, 1)    last_day = datetime.date(year, month, calendar.monthrange(year, month)[1])return {'first_day': first_day,'last_day': last_day    }# 示例month_days = get_month_first_last_day(202310)print(f"2023年10月的第一天和最后一天: {month_days}"# {'first_day': datetime.date(2023, 10, 1), 'last_day': datetime.date(2023, 10, 31)}

案例40:  增加或减少日期

import datetimedefadd_days_to_date(date_obj, days_to_add):"""给日期增加指定天数."""    delta = datetime.timedelta(days=days_to_add)return date_obj + deltadefsubtract_days_from_date(date_obj, days_to_subtract):"""给日期减少指定天数."""    delta = datetime.timedelta(days=days_to_subtract)return date_obj - delta# 示例today = datetime.date.today()future_date = add_days_to_date(today, 7# 7 天后past_date = subtract_days_from_date(today, 3# 3 天前print(f"7 天后: {future_date}, 3 天前: {past_date}")

5. 实用工具与技巧

最后,我们来看一些常用的实用工具和编程技巧。

案例41:  生成随机整数

import randomdefgenerate_random_integer(start, end):"""生成指定范围内的随机整数."""return random.randint(start, end)# 示例random_number = generate_random_integer(1100)print(f"随机整数 (1-100): {random_number}")

案例42:  生成随机浮点数

import randomdefgenerate_random_float(start, end):"""生成指定范围内的随机浮点数."""return random.uniform(start, end)# 示例random_float = generate_random_float(01)print(f"随机浮点数 (0-1): {random_float}")

案例43:  从列表中随机选择一个元素

import randomdefchoose_random_item_from_list(data_list):"""从列表中随机选择一个元素."""ifnot data_list:return"列表为空"return random.choice(data_list)# 示例my_list = ['apple''banana''cherry']random_item = choose_random_item_from_list(my_list)print(f"随机选择的元素: {random_item}")

案例44:  打乱列表顺序

import randomdefshuffle_list(data_list):"""打乱列表顺序 (原地修改)."""    random.shuffle(data_list)return data_list# 示例my_list = [12345]shuffled_list = shuffle_list(my_list.copy()) # 避免修改原列表print(f"打乱后的列表: {shuffled_list}")

案例45:  计算代码运行时间

import timedefcalculate_execution_time(func, *args, **kwargs):"""计算函数运行时间 (秒)."""    start_time = time.time()    result = func(*args, **kwargs)    end_time = time.time()    execution_time = end_time - start_timereturn execution_time, result # 返回运行时间和函数结果# 示例函数 (计算平方和)defsum_of_squares(n):return sum([i**2for i in range(n)])execution_time, result = calculate_execution_time(sum_of_squares, 100000)print(f"函数运行时间: {execution_time:.4f} 秒, 结果: {result}")

案例46:  简单的命令行参数解析

import argparsedefparse_command_line_arguments():"""使用 argparse 解析命令行参数."""    parser = argparse.ArgumentParser(description="一个简单的命令行工具")    parser.add_argument("filename", help="要处理的文件名")    parser.add_argument("-n""--number", type=int, help="一个数字参数", default=10)    args = parser.parse_args()return args# 示例 (在命令行中运行: python your_script_name.py input.txt -n 20)# args = parse_command_line_arguments()# print(f"文件名: {args.filename}, 数字参数: {args.number}")

案例47:  密码生成器 (简单版)

import randomimport stringdefgenerate_password(length=12):"""生成指定长度的随机密码,包含字母和数字."""    characters = string.ascii_letters + string.digits    password = ''.join(random.choice(characters) for i in range(length))return password# 示例password = generate_password(16)print(f"随机密码: {password}")

案例48:  简单的邮件发送 (需要配置SMTP服务器)

import smtplibfrom email.mime.text import MIMETextdefsend_email(sender_email, sender_password, receiver_email, subject, message, smtp_server='smtp.example.com', smtp_port=587):"""发送邮件 (需要配置SMTP服务器)."""    msg = MIMEText(message)    msg['Subject'] = subject    msg['From'] = sender_email    msg['To'] = receiver_emailtry:        server = smtplib.SMTP(smtp_server, smtp_port)        server.starttls() # 启用 TLS 加密        server.login(sender_email, sender_password) # 登录邮箱        server.sendmail(sender_email, [receiver_email], msg.as_string())        server.quit()return"邮件发送成功"except Exception as e:returnf"邮件发送失败: {e}"#  **请注意:**  出于安全考虑,不要在代码中硬编码您的邮箱密码。#  示例 (请替换为您的邮箱信息和目标邮箱)#  sender = "your_email@example.com"#  password = "your_email_password"#  receiver = "recipient_email@example.com"#  email_result = send_email(sender, password, receiver, "测试邮件", "这是一封测试邮件。")#  print(email_result)

案例49:  简单的文本替换

defreplace_text_in_string(text, old_substring, new_substring):"""在字符串中替换子字符串."""return text.replace(old_substring, new_substring)# 示例original_text = "Hello World! World is great."replaced_text = replace_text_in_string(original_text, "World""Python")print(f"替换后的文本: {replaced_text}"# Hello Python! Python is great.

案例50:  使用 try-except 处理异常

defsafe_integer_division(numerator, denominator):"""安全地进行整数除法,处理除零异常."""try:        result = numerator / denominatorreturn resultexcept ZeroDivisionError:return"除数不能为零"except TypeError:return"输入类型错误,请输入数字"# 示例division_result1 = safe_integer_division(102)division_result2 = safe_integer_division(100)division_result3 = safe_integer_division(10'a')print(f"10 / 2 = {division_result1}"# 5.0print(f"10 / 0 = {division_result2}"# 除数不能为零print(f"10 / 'a' = {division_result3}"# 输入类型错误,请输入数字

结语:

这50个Python代码小案例只是Python强大功能的冰山一角。希望这些“拿来即用”的代码片段能帮助您更高效地完成日常编程任务!

长按或扫描下方二维码,免费获取 Python公开课和大佬打包整理的几百G的学习资料,内容包含但不限于Python电子书、教程、项目接单、源码等等

推荐阅读

写Python到底用什么编辑器好?鹅厂程序猿吵翻了

从 Exception 到 BaseException:构建符合 Python 哲学

Python 提速 20%,来看看 Python 3.15 中的新特性

Python向量搜索实战:让14万文档的检索速度提升54倍!

点击 阅读原文 了解更多

最新文章

随机文章

基本 文件 流程 错误 SQL 调试
  1. 请求信息 : 2026-02-08 21:43:08 HTTP/2.0 GET : https://f.mffb.com.cn/a/461160.html
  2. 运行时间 : 0.096416s [ 吞吐率:10.37req/s ] 内存消耗:4,702.94kb 文件加载:140
  3. 缓存信息 : 0 reads,0 writes
  4. 会话信息 : SESSION_ID=b6988ff4979c8b5ed2b5f51c3082e285
  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.000538s ] mysql:host=127.0.0.1;port=3306;dbname=f_mffb;charset=utf8mb4
  2. SHOW FULL COLUMNS FROM `fenlei` [ RunTime:0.000741s ]
  3. SELECT * FROM `fenlei` WHERE `fid` = 0 [ RunTime:0.000698s ]
  4. SELECT * FROM `fenlei` WHERE `fid` = 63 [ RunTime:0.000296s ]
  5. SHOW FULL COLUMNS FROM `set` [ RunTime:0.000604s ]
  6. SELECT * FROM `set` [ RunTime:0.001894s ]
  7. SHOW FULL COLUMNS FROM `article` [ RunTime:0.000600s ]
  8. SELECT * FROM `article` WHERE `id` = 461160 LIMIT 1 [ RunTime:0.000737s ]
  9. UPDATE `article` SET `lasttime` = 1770558188 WHERE `id` = 461160 [ RunTime:0.006542s ]
  10. SELECT * FROM `fenlei` WHERE `id` = 66 LIMIT 1 [ RunTime:0.000271s ]
  11. SELECT * FROM `article` WHERE `id` < 461160 ORDER BY `id` DESC LIMIT 1 [ RunTime:0.000467s ]
  12. SELECT * FROM `article` WHERE `id` > 461160 ORDER BY `id` ASC LIMIT 1 [ RunTime:0.000700s ]
  13. SELECT * FROM `article` WHERE `id` < 461160 ORDER BY `id` DESC LIMIT 10 [ RunTime:0.006132s ]
  14. SELECT * FROM `article` WHERE `id` < 461160 ORDER BY `id` DESC LIMIT 10,10 [ RunTime:0.000998s ]
  15. SELECT * FROM `article` WHERE `id` < 461160 ORDER BY `id` DESC LIMIT 20,10 [ RunTime:0.003757s ]
0.098129s