欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

WxPython開發(fā)之實(shí)現(xiàn)表格數(shù)據(jù)導(dǎo)出到Excel并打開

 更新時(shí)間:2024年12月10日 08:18:23   作者:伍華聰  
在 Python 中使用 wxPython 導(dǎo)出實(shí)體類列表數(shù)據(jù)到 Excel,通常可以借助 openpyxl 或 pandas 庫來實(shí)現(xiàn),下面就跟隨小編一起來了解下具體操作吧

在 Python 中使用 wxPython 導(dǎo)出實(shí)體類列表數(shù)據(jù)到 Excel,通??梢越柚?nbsp;openpyxl 或 pandas 庫來實(shí)現(xiàn)。本篇隨筆由淺入深,逐步介紹導(dǎo)出Excel文件的操作,然后結(jié)合跨平臺項(xiàng)目的實(shí)現(xiàn),根據(jù)抽象繼承的方式,對不同業(yè)務(wù)模塊的通用導(dǎo)出Excel文件功能,以及跨平臺的打開處理方式的實(shí)現(xiàn)進(jìn)行介紹。

以下是一個(gè)基本示例,展示如何將實(shí)體類的列表數(shù)據(jù)導(dǎo)出到 Excel 文件。

1、使用pandas 庫導(dǎo)出Excel

import wx
import pandas as pd

# 假設(shè)這是你的實(shí)體類
class Person:
    def __init__(self, name, age, email):
        self.name = name
        self.age = age
        self.email = email

    def to_dict(self):
        return {"Name": self.name, "Age": self.age, "Email": self.email}

# 用一個(gè) wxPython 窗口展示如何導(dǎo)出數(shù)據(jù)
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super().__init__(parent, title=title, size=(300, 200))
        
        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel, label="導(dǎo)出到Excel", pos=(50, 50))
        
        # 創(chuàng)建一些實(shí)體類數(shù)據(jù)
        self.person_list = [
            Person("Alice", 30, "alice@example.com"),
            Person("Bob", 25, "bob@example.com"),
            Person("Charlie", 35, "charlie@example.com")
        ]
        
        self.Bind(wx.EVT_BUTTON, self.export_to_excel, self.button)
        self.Show()

    def export_to_excel(self, event):
        # 將實(shí)體類列表轉(zhuǎn)換為字典列表
        data = [person.to_dict() for person in self.person_list]
        
        # 使用 pandas 導(dǎo)出到 Excel
        df = pd.DataFrame(data)
        df.to_excel("exported_data.xlsx", index=False)
        
        wx.MessageBox("導(dǎo)出成功!", "信息", wx.OK | wx.ICON_INFORMATION)

# 啟動 wxPython 應(yīng)用
app = wx.App(False)
frame = MyFrame(None, "導(dǎo)出實(shí)體類數(shù)據(jù)到 Excel")
app.MainLoop()

實(shí)體類 (Person):包含一些字段,如 name、age 和 email,并定義了 to_dict 方法,將實(shí)體對象轉(zhuǎn)換為字典格式,以便更容易處理。

export_to_excel:這個(gè)方法將實(shí)體類列表轉(zhuǎn)換為字典列表,使用 pandas 庫將數(shù)據(jù)導(dǎo)出為 Excel 文件。

如果你需要更多的功能(如自定義 Excel 格式,單元格樣式等),可以進(jìn)一步擴(kuò)展 openpyxl 或 xlsxwriter 來提供更復(fù)雜的導(dǎo)出選項(xiàng)。

2、使用 openpyxl 庫導(dǎo)出Excel

要在 Excel 導(dǎo)出時(shí)為標(biāo)題加粗并設(shè)置背景色,你可以使用 openpyxl 庫,它提供了豐富的功能來設(shè)置單元格樣式(如字體、背景色等)。

以下是一個(gè)更新的示例,演示如何在導(dǎo)出數(shù)據(jù)時(shí),設(shè)置 Excel 標(biāo)題行的加粗和背景色。

import wx
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill

# 假設(shè)這是你的實(shí)體類
class Person:
    def __init__(self, name, age, email):
        self.name = name
        self.age = age
        self.email = email

    def to_dict(self):
        return {"Name": self.name, "Age": self.age, "Email": self.email}

# 用一個(gè) wxPython 窗口展示如何導(dǎo)出數(shù)據(jù)
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super().__init__(parent, title=title, size=(300, 200))
        
        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel, label="導(dǎo)出到Excel", pos=(50, 50))
        
        # 創(chuàng)建一些實(shí)體類數(shù)據(jù)
        self.person_list = [
            Person("Alice", 30, "alice@example.com"),
            Person("Bob", 25, "bob@example.com"),
            Person("Charlie", 35, "charlie@example.com")
        ]
        
        self.Bind(wx.EVT_BUTTON, self.export_to_excel, self.button)
        self.Show()

    def export_to_excel(self, event):
        # 將實(shí)體類列表轉(zhuǎn)換為字典列表
        data = [person.to_dict() for person in self.person_list]
        
        # 創(chuàng)建 Excel 工作簿和工作表
        wb = Workbook()
        ws = wb.active
        ws.title = "People Data"
        
        # 設(shè)置標(biāo)題行并加粗背景色
        titles = ["Name", "Age", "Email"]
        ws.append(titles)
        
        # 設(shè)置標(biāo)題樣式:加粗和背景色
        title_font = Font(bold=True)
        title_fill = PatternFill(start_color="FFFF00", end_color="FFFF00", fill_type="solid")  # 黃色背景
        for cell in ws[1]:
            cell.font = title_font
            cell.fill = title_fill
        
        # 填充數(shù)據(jù)
        for person in data:
            ws.append([person["Name"], person["Age"], person["Email"]])
        
        # 保存到文件
        wb.save("exported_data_with_styles.xlsx")
        
        wx.MessageBox("導(dǎo)出成功!", "信息", wx.OK | wx.ICON_INFORMATION)

# 啟動 wxPython 應(yīng)用
app = wx.App(False)
frame = MyFrame(None, "導(dǎo)出實(shí)體類數(shù)據(jù)到 Excel")
app.MainLoop()

Excel 在 openpyxl 中可以設(shè)置自適應(yīng)列寬或者指定具體的列寬,甚至可以設(shè)置框架(邊框樣式)。

雖然 openpyxl 本身并沒有直接提供“自動調(diào)整列寬”的功能,但我們可以通過遍歷列中的所有單元格來計(jì)算每列的最大寬度,然后動態(tài)調(diào)整列寬。

調(diào)整后的代碼如下所示。

import wx
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Border, Side

# 假設(shè)這是你的實(shí)體類
class Person:
    def __init__(self, name, age, email):
        self.name = name
        self.age = age
        self.email = email

    def to_dict(self):
        return {"Name": self.name, "Age": self.age, "Email": self.email}

# 用一個(gè) wxPython 窗口展示如何導(dǎo)出數(shù)據(jù)
class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super().__init__(parent, title=title, size=(300, 200))
        
        self.panel = wx.Panel(self)
        self.button = wx.Button(self.panel, label="導(dǎo)出到Excel", pos=(50, 50))
        
        # 創(chuàng)建一些實(shí)體類數(shù)據(jù)
        self.person_list = [
            Person("Alice", 30, "alice@example.com"),
            Person("Bob", 25, "bob@example.com"),
            Person("Charlie", 35, "charlie@example.com")
        ]
        
        self.Bind(wx.EVT_BUTTON, self.export_to_excel, self.button)
        self.Show()

    def export_to_excel(self, event):
        # 將實(shí)體類列表轉(zhuǎn)換為字典列表
        data = [person.to_dict() for person in self.person_list]
        
        # 創(chuàng)建 Excel 工作簿和工作表
        wb = Workbook()
        ws = wb.active
        ws.title = "People Data"
        
        # 設(shè)置標(biāo)題行并加粗背景色
        titles = ["Name", "Age", "Email"]
        ws.append(titles)
        
        # 設(shè)置標(biāo)題樣式:加粗和背景色
        title_font = Font(bold=True)
        title_fill = PatternFill(start_color="FFFF00", end_color="FFFF00", fill_type="solid")  # 黃色背景
        for cell in ws[1]:
            cell.font = title_font
            cell.fill = title_fill
        
        # 填充數(shù)據(jù)
        for person in data:
            ws.append([person["Name"], person["Age"], person["Email"]])
        
        # 設(shè)置列寬(手動指定或根據(jù)內(nèi)容自適應(yīng))
        # 自動調(diào)整列寬
        for col in ws.columns:
            max_length = 0
            column = col[0].column_letter  # 獲取列字母
            for cell in col:
                try:
                    if len(str(cell.value)) > max_length:
                        max_length = len(cell.value)
                except:
                    pass
            adjusted_width = (max_length + 2)
            ws.column_dimensions[column].width = adjusted_width
        
        # 設(shè)置框架(邊框)
        border = Border(
            left=Side(border_style="thin"),
            right=Side(border_style="thin"),
            top=Side(border_style="thin"),
            bottom=Side(border_style="thin")
        )
        for row in ws.iter_rows():
            for cell in row:
                cell.border = border
        
        # 保存到文件
        wb.save("exported_data_with_styles_and_borders.xlsx")
        
        wx.MessageBox("導(dǎo)出成功!", "信息", wx.OK | wx.ICON_INFORMATION)

# 啟動 wxPython 應(yīng)用
app = wx.App(False)
frame = MyFrame(None, "導(dǎo)出實(shí)體類數(shù)據(jù)到 Excel")
app.MainLoop()

點(diǎn)擊“導(dǎo)出到Excel”按鈕后,程序?qū)⑸梢粋€(gè)包含:

  • 自動調(diào)整列寬的 Excel 文件;
  • 每個(gè)單元格的邊框;
  • 標(biāo)題行加粗并帶黃色背景色的 Excel 文件。

為了實(shí)現(xiàn)一個(gè)通用的導(dǎo)出函數(shù),根據(jù) display_columns 和 column_mapping 設(shè)置導(dǎo)出的字段,并映射標(biāo)題名稱,你可以設(shè)計(jì)一個(gè)靈活的函數(shù),接收這些參數(shù)并根據(jù)需要導(dǎo)出數(shù)據(jù)到 Excel。

  • display_columns:一個(gè)字符串,指定需要導(dǎo)出的字段(如 name,age,email)。
  • column_mapping:一個(gè)字典,指定字段到顯示名稱的映射。
  • list:包含實(shí)體類數(shù)據(jù)的列表,每個(gè)實(shí)體類需要提供 to_dict() 方法,將數(shù)據(jù)轉(zhuǎn)換為字典格式。
  • filename:保存的文件名。
import wx
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Border, Side

def export_to_excel(list_data, display_columns, column_mapping, filename):
    # 解析 display_columns 為列表
    display_columns = display_columns.split(',')
    
    # 獲取映射后的標(biāo)題
    headers = [column_mapping.get(col, col) for col in display_columns]

    # 創(chuàng)建 Excel 工作簿和工作表
    wb = Workbook()
    ws = wb.active
    ws.title = "Data"

    # 設(shè)置標(biāo)題行并加粗背景色
    ws.append(headers)
    title_font = Font(bold=True)
    title_fill = PatternFill(start_color="FFFF00", end_color="FFFF00", fill_type="solid")  # 黃色背景
    for cell in ws[1]:
        cell.font = title_font
        cell.fill = title_fill

    # 填充數(shù)據(jù)
    for data_item in list_data:
        row = [data_item.get(col) for col in display_columns]
        ws.append(row)

    # 設(shè)置列寬(自動調(diào)整)
    for col in ws.columns:
        max_length = 0
        column = col[0].column_letter  # 獲取列字母
        for cell in col:
            try:
                if len(str(cell.value)) > max_length:
                    max_length = len(cell.value)
            except:
                pass
        adjusted_width = (max_length + 2)
        ws.column_dimensions[column].width = adjusted_width

    # 設(shè)置框架(邊框)
    border = Border(
        left=Side(border_style="thin"),
        right=Side(border_style="thin"),
        top=Side(border_style="thin"),
        bottom=Side(border_style="thin")
    )
    for row in ws.iter_rows():
        for cell in row:
            cell.border = border

    # 保存到文件
    wb.save(filename)
    return f"導(dǎo)出成功!文件已保存為 {filename}"

調(diào)用代碼如下所示

    def export(self, event):
        display_columns = "name,age,email"  # 需要導(dǎo)出的字段
        column_mapping = { 
            "age": "年齡", 
            "email": "電子郵箱", 
            "name": "顯示名稱"
        }
        filename = "exported_data.xlsx"  # 保存的文件名
        result = export_to_excel(
            [person.to_dict() for person in self.person_list], 
            display_columns, 
            column_mapping, 
            filename
        )
        wx.MessageBox(result, "信息", wx.OK | wx.ICON_INFORMATION)

你只需調(diào)用 export_to_excel 函數(shù)并傳遞數(shù)據(jù)、要導(dǎo)出的字段(display_columns)、字段映射(column_mapping)和保存的文件名(filename)。它會生成一個(gè) Excel 文件,并按要求設(shè)置樣式。

在 openpyxl 中,自動調(diào)整列寬是通過檢查列中內(nèi)容的最大長度來實(shí)現(xiàn)的。如果你發(fā)現(xiàn)某一列(例如“年齡”列)的寬度過窄,可能是因?yàn)樵摿兄械臄?shù)據(jù)(例如數(shù)字)被視為較短的字符串,導(dǎo)致列寬過小。

為了解決這個(gè)問題,您可以通過設(shè)置列寬時(shí)為數(shù)字列提供額外的寬度補(bǔ)償,或者通過在計(jì)算列寬時(shí)增加一個(gè)常量來確保列寬更合適。

    # 設(shè)置列寬(自動調(diào)整)
    for col in ws.columns:
        max_length = 0
        column = col[0].column_letter  # 獲取列字母
        for cell in col:
            try:
                if cell.value:
                    cell_value = str(cell.value)
                    # 增加補(bǔ)償寬度:如果是數(shù)字列,增加額外寬度
                    if isinstance(cell.value, (int, float)):
                        max_length = max(max_length, len(cell_value) + 2)  # 數(shù)字列增加 2 的寬度
                    else:
                        max_length = max(max_length, len(cell_value))
            except:
                pass
        adjusted_width = (max_length + 2)  # 留出一些額外的空間
        ws.column_dimensions[column].width = max(adjusted_width, 12)  # 設(shè)置最小寬度為 12
  • 列寬補(bǔ)償:對于數(shù)字列(如 age 列),在計(jì)算最大長度時(shí)增加一個(gè) +2 的補(bǔ)償。這將確保數(shù)字列的列寬足夠顯示數(shù)字值。
  • 最小列寬:為了避免列過窄,我設(shè)置了 max(adjusted_width, 12),確保列寬至少為 12。如果計(jì)算出的列寬小于 12,將強(qiáng)制設(shè)置為 12。
  • 自動列寬:自動計(jì)算每列的最大長度,并為每列分配合適的寬度。

如果我們需要再實(shí)際業(yè)務(wù)中導(dǎo)出數(shù)據(jù),如對于用戶信息,實(shí)體類為UserDto,那么我們需要在導(dǎo)出數(shù)據(jù)之前,將 UserDto 類型的對象轉(zhuǎn)換為字典格式。

在每個(gè) DTO 對象中,添加一個(gè) to_dict 方法,用于將對象的屬性轉(zhuǎn)換為字典。to_dict 方法可以返回一個(gè)字典,其中每個(gè)鍵是類屬性的名稱,每個(gè)值是對應(yīng)的屬性值。

不過我的跨平臺框架中的UserDto對象是與Pydantic模型的,因此它可以通過函數(shù) model_dump  進(jìn)行通用處理為字典對象。

使用 model_dump 方法可以很方便地將 Python 類對象(特別是 Pydantic 模型或者具備 model_dump 方法的類)轉(zhuǎn)換為字典。如果你正在使用 Pydantic 或者使用了某些自定義實(shí)現(xiàn)了 model_dump 方法的類,可以直接調(diào)用該方法來完成對象到字典的轉(zhuǎn)換。

假設(shè)你有一個(gè) UserDto 類,它是一個(gè) Pydantic 模型:

from pydantic import BaseModel

class UserDto(BaseModel):
    name: str
    age: int
    email: str

# 創(chuàng)建一個(gè) UserDto 實(shí)例
user = UserDto(name="Alice", age=30, email="alice@example.com")

# 使用 model_dump 將對象轉(zhuǎn)換為字典
user_dict = user.model_dump()

print(user_dict)

在這個(gè)例子中,model_dump 會自動將 Pydantic 模型實(shí)例轉(zhuǎn)換為字典,所有字段(即類的屬性)都會成為字典的鍵,屬性值成為字典的值。

如果你有嵌套的 Pydantic 模型,model_dump 會自動遞歸地將嵌套模型轉(zhuǎn)換為字典。如果你的項(xiàng)目中使用了 Pydantic,這種方法將非常簡便高效。

3、在項(xiàng)目列表基類中增加導(dǎo)出功能

通過上面的封裝測試,我們可以把導(dǎo)出Excel的功能做的很不錯(cuò)了,因此把它整合到列表基類里面,通過基類界面中增加一個(gè)導(dǎo)出按鈕即可實(shí)現(xiàn)所有業(yè)務(wù)模塊的數(shù)據(jù)導(dǎo)出,不用每個(gè)頁面都實(shí)現(xiàn),簡化了操作。

添加按鈕采用通用輔助函數(shù)參加按鈕及圖標(biāo),并增加導(dǎo)出的處理函數(shù),如下代碼所示。

  btn_export = ControlUtil.create_button(
      pane, "導(dǎo)出Excel", "xls", handler=self.OnExport, is_async=True
  )

OnExport函數(shù)的實(shí)現(xiàn)如下所示。

    async def OnExport(self, event: wx.Event) -> None:
        """導(dǎo)出數(shù)據(jù)"""
        # 檢查數(shù)據(jù)是否是一個(gè) Pydantic 實(shí)體
        export_list = []
        for item in self.data:
            if hasattr(item, "model_dump"):
                export_item = item.model_dump()
                export_list.append(export_item)
            else:
                export_list.append(item)

        # print(export_list)

        filename = FileDialogUtil.save_excel(self)
        if not filename:
            return

        result = ExcelUtil.export_to_excel(
            export_list, self.display_columns, self.column_mapping, filename
        )
        if result:
            if (
                MessageUtil.show_confirm(self, "導(dǎo)出成功,是否打開文件?", "導(dǎo)出成功")
                == wx.ID_YES
            ):
                ExcelUtil.open_file(filename)
        else:
            MessageUtil.show_error(self, "導(dǎo)出失敗")

在MacOS上彈出導(dǎo)出提示,如下所示。

確認(rèn)后提示,是否打開文件如下。

導(dǎo)出的文件打開后,可以看到效果如下所示

4、文件的打開方式和跨平臺打開實(shí)現(xiàn)

注意,不同平臺打開文件進(jìn)行查看,操作方式有所不同。

如果你想用默認(rèn)應(yīng)用(如 Excel 或 Numbers)直接打開 .xls 文件,你可以通過 Python 的 subprocess 模塊調(diào)用 macOS 上的應(yīng)用程序來打開文件。

在 macOS 中,open 命令可以用來打開任何文件。如果你希望在默認(rèn)的應(yīng)用程序中打開 .xls 文件(例如 Excel 或 Numbers),可以使用如下方法:

import subprocess

# 打開 .xls 文件
subprocess.run(["open", "your_file.xls"])

macOS 支持通過 os 模塊調(diào)用系統(tǒng)命令來打開文件??梢酝ㄟ^ os.system() 或 subprocess.run() 來調(diào)用 open 命令,在 macOS 上打開文件。

import os

# 打開 .xls 文件
os.system("open your_file.xls")

通過 os.system("open your_file.xls") 或 subprocess.run(["open", "your_file.xls"]),你可以在 macOS 上使用默認(rèn)的應(yīng)用程序(如 Excel 或 Numbers)打開 .xls 文件。這些方法非常簡單且不需要依賴外部庫。

os.startfile() 是 Windows 系統(tǒng)中的一個(gè)特定方法,用于打開文件并在關(guān)聯(lián)的默認(rèn)應(yīng)用程序中顯示它。然而,os.startfile() 在 macOS 和 Linux 系統(tǒng)中不可用。因此,在 macOS 上使用該方法會導(dǎo)致錯(cuò)誤。

為了使代碼在不同平臺上都能工作,您可以編寫一個(gè)條件判斷,區(qū)分操作系統(tǒng)并使用合適的命令來打開文件。

import os
import subprocess
import platform

def open_file(file_path):
    system = platform.system()
    
    if system == "Darwin":  # macOS
        subprocess.run(["open", file_path])
    elif system == "Windows":
        os.startfile(file_path)
    elif system == "Linux":
        subprocess.run(["xdg-open", file_path])
    else:
        raise NotImplementedError(f"Unsupported operating system: {system}")

# 示例調(diào)用
open_file("your_file.xls")

說明:

  • macOS (Darwin):使用 open 命令。
  • Windows:使用 os.startfile(),這是 Windows 特有的方法。
  • Linux:使用 xdg-open 命令,適用于大多數(shù) Linux 發(fā)行版。

對于跨平臺執(zhí)行系統(tǒng)命令,推薦使用 subprocess 模塊,它提供了更強(qiáng)大的功能,并且更靈活和安全。subprocess.run() 方法是一個(gè)更通用的替代方案。

因此結(jié)合通用的導(dǎo)出Excel和打開文件,就可以實(shí)現(xiàn)Excel文件的導(dǎo)出打開操作了,各個(gè)業(yè)務(wù)列表模塊度是基于列表基礎(chǔ)頁面的,因此自動具有導(dǎo)出的功能,當(dāng)然,我們也可以根據(jù)一些條件進(jìn)行判斷是否使用導(dǎo)出按鈕即可。

列表界面繼承基類,從而可以大幅度的利用相應(yīng)的規(guī)則和實(shí)現(xiàn)。

 

 如對于兩個(gè)例子窗體:系統(tǒng)類型定義,客戶信息,其中傳如對應(yīng)的DTO信息和參數(shù)即可。

子類繼承基類列表頁面,并傳入對應(yīng)的參數(shù)即可具體化相關(guān)的業(yè)務(wù)功能了。

以上就是根據(jù)抽象繼承的方式,對不同業(yè)務(wù)模塊的通用導(dǎo)出Excel文件功能,以及跨平臺的打開處理方式的實(shí)現(xiàn)。

以上就是WxPython開發(fā)之實(shí)現(xiàn)表格數(shù)據(jù)導(dǎo)出到Excel并打開的詳細(xì)內(nèi)容,更多關(guān)于WxPython數(shù)據(jù)導(dǎo)出到Excel的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • Python的Django框架中的URL配置與松耦合

    Python的Django框架中的URL配置與松耦合

    這篇文章主要介紹了Python的Django框架中的URL配置與松耦合,文中簡單講解了這一松耦合原則,需要的朋友可以參考下
    2015-07-07
  • Python進(jìn)階之高級用法詳細(xì)總結(jié)

    Python進(jìn)階之高級用法詳細(xì)總結(jié)

    今天帶各位小伙伴學(xué)習(xí)一下Python高級語法,主要有Lambda表達(dá)式,map函數(shù),filter函數(shù),reduce函數(shù),三大推導(dǎo)式等,文中有非常詳細(xì)的介紹,需要的朋友可以參考下
    2021-05-05
  • 基于python分布式爬蟲并解決假死的問題

    基于python分布式爬蟲并解決假死的問題

    這篇文章主要介紹了基于python分布式爬蟲并解決假死的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2021-04-04
  • 深度定制Python的Flask框架開發(fā)環(huán)境的一些技巧總結(jié)

    深度定制Python的Flask框架開發(fā)環(huán)境的一些技巧總結(jié)

    現(xiàn)在越來越多的人使用virtualenv虛擬環(huán)境部署Python項(xiàng)目,包括針對框架的實(shí)例文件夾與版本控制布置,這里我們就來整理關(guān)于深度定制Python的Flask框架開發(fā)環(huán)境的一些技巧總結(jié)
    2016-07-07
  • Python一個(gè)簡單的通信程序(客戶端 服務(wù)器)

    Python一個(gè)簡單的通信程序(客戶端 服務(wù)器)

    今天小編就為大家分享一篇關(guān)于Python一個(gè)簡單的通信程序(客戶端 服務(wù)器),小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • Python的re模塊正則表達(dá)式操作

    Python的re模塊正則表達(dá)式操作

    這篇文章主要介紹了Python的re模塊正則表達(dá)式操作 的相關(guān)資料,需要的朋友可以參考下
    2016-05-05
  • 解決nohup重定向python輸出到文件不成功的問題

    解決nohup重定向python輸出到文件不成功的問題

    今天小編就為大家分享一篇解決nohup重定向python輸出到文件不成功的問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-05-05
  • 利用20行Python 代碼實(shí)現(xiàn)加密通信

    利用20行Python 代碼實(shí)現(xiàn)加密通信

    這篇文章主要介紹了利用Python 代碼實(shí)現(xiàn)加密通信,本文用 20 行 Python 代碼來演示加密、解密、簽名、驗(yàn)證的功能。大家依樣畫葫蘆,不僅能理解加密技術(shù),更能自己實(shí)現(xiàn)一套加密通信機(jī)制,需要的朋友可以參考一下
    2022-03-03
  • 玩轉(zhuǎn)python爬蟲之爬取糗事百科段子

    玩轉(zhuǎn)python爬蟲之爬取糗事百科段子

    這篇文章主要介紹了python爬蟲爬取糗事百科段子,詳細(xì)介紹下,如何來抓取到糗事百科里面的指定內(nèi)容,感興趣的小伙伴們可以參考一下
    2016-02-02
  • Python Matplotlib 庫使用指南

    Python Matplotlib 庫使用指南

    這篇文章主要介紹了Python Matplotlib 庫使用基本指南,通過本教程,我們學(xué)習(xí)了使用 Matplotlib 創(chuàng)建各種類型的圖表和圖形,Matplotlib 提供了豐富的函數(shù)和選項(xiàng),以滿足不同的數(shù)據(jù)可視化需求,需要的朋友可以參考下
    2024-01-01

最新評論