{"id":987774,"date":"2024-12-27T07:56:18","date_gmt":"2024-12-26T23:56:18","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/987774.html"},"modified":"2024-12-27T07:56:20","modified_gmt":"2024-12-26T23:56:20","slug":"python%e9%87%8c%e5%a6%82%e4%bd%95%e8%ae%be%e7%bd%ae%e5%ad%97%e4%bd%93","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/987774.html","title":{"rendered":"python\u91cc\u5982\u4f55\u8bbe\u7f6e\u5b57\u4f53"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25063730\/1100a014-bdb3-43ef-b761-17bde45bd67d.webp\" alt=\"python\u91cc\u5982\u4f55\u8bbe\u7f6e\u5b57\u4f53\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u4e3b\u8981\u6d89\u53ca\u5230\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u7f16\u7a0b\u6216\u56fe\u5f62\u7ed8\u5236\u4efb\u52a1\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecTkinter\u3001Pygame\u548cMatplotlib\u7b49\u3002<strong>\u5728Python\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u4f7f\u7528Tkinter\u5e93\u7684<code>font<\/code>\u6a21\u5757\u3001\u5728Pygame\u4e2d\u901a\u8fc7<code>pygame.font.Font<\/code>\u7c7b\u3001\u4ee5\u53ca\u5728Matplotlib\u4e2d\u901a\u8fc7<code>fontdict<\/code>\u53c2\u6570<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u4e2d\u5b9e\u73b0\u5b57\u4f53\u7684\u5b9a\u5236\u5316\uff0c\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5176\u4e2d\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528Tkinter\u5e93\u7684<code>font<\/code>\u6a21\u5757\u662f\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u4e4b\u4e00\u3002Tkinter\u662fPython\u7684\u6807\u51c6GUI\u5e93\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u7b80\u5355\u800c\u5f3a\u5927\u7684\u5b57\u4f53\u8bbe\u7f6e\u65b9\u5f0f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7<code>tkinter.font.Font<\/code>\u7c7b\u6765\u6307\u5b9a\u5b57\u4f53\u7684\u540d\u79f0\u3001\u5927\u5c0f\u3001\u6837\u5f0f\uff08\u5982\u7c97\u4f53\u3001\u659c\u4f53\u7b49\uff09\u3002\u4f8b\u5982\uff0c\u901a\u8fc7\u4ee5\u4e0b\u4ee3\u7801\u53ef\u4ee5\u5728Tkinter\u5e94\u7528\u4e2d\u8bbe\u7f6e\u4e00\u4e2a\u6807\u7b7e\u7684\u5b57\u4f53\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tkinter as tk<\/p>\n<p>from tkinter import font<\/p>\n<p>root = tk.Tk()<\/p>\n<p>custom_font = font.Font(family=&quot;Helvetica&quot;, size=12, weight=&quot;bold&quot;)<\/p>\n<p>label = tk.Label(root, text=&quot;Hello, World!&quot;, font=custom_font)<\/p>\n<p>label.pack()<\/p>\n<p>root.m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u5bfc\u5165\u4e86<code>tkinter<\/code>\u6a21\u5757\u53ca\u5176<code>font<\/code>\u5b50\u6a21\u5757\uff0c\u7136\u540e\u521b\u5efa\u4e86\u4e00\u4e2a<code>Font<\/code>\u5bf9\u8c61<code>custom_font<\/code>\uff0c\u5e76\u6307\u5b9a\u4e86\u5b57\u4f53\u5bb6\u65cf\u4e3a\u201cHelvetica\u201d\u3001\u5b57\u53f7\u4e3a12\u3001\u5b57\u4f53\u52a0\u7c97\u3002\u63a5\u7740\uff0c\u6211\u4eec\u5c06\u8fd9\u4e2a\u5b57\u4f53\u5e94\u7528\u5230\u4e00\u4e2a\u6807\u7b7e\u63a7\u4ef6\u4e0a\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u4e00\u3001\u4f7f\u7528TKINTER\u8bbe\u7f6e\u5b57\u4f53<\/p>\n<\/p>\n<p><p>Tkinter\u662fPython\u7684\u6807\u51c6GUI\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u5e76\u4e14\u5176<code>font<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u7075\u6d3b\u7684\u5b57\u4f53\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efaTkinter\u5e94\u7528\u7a0b\u5e8f<\/strong><br \/>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efa\u4e00\u4e2aTkinter\u7a97\u53e3\uff0c\u5e76\u5bfc\u5165<code>tkinter<\/code>\u548c<code>font<\/code>\u6a21\u5757\u3002\u901a\u8fc7<code>tkinter.Tk()<\/code>\u65b9\u6cd5\u521b\u5efa\u4e3b\u7a97\u53e3\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import tkinter as tk<\/p>\n<p>from tkinter import font<\/p>\n<p>root = tk.Tk()<\/p>\n<p>root.title(&quot;Font Example&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u81ea\u5b9a\u4e49\u5b57\u4f53<\/strong><br \/>\u4f7f\u7528<code>font.Font<\/code>\u7c7b\u5b9a\u4e49\u81ea\u5b9a\u4e49\u5b57\u4f53\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u5b57\u4f53\u5bb6\u65cf\u3001\u5927\u5c0f\u3001\u52a0\u7c97\u3001\u659c\u4f53\u7b49\u5c5e\u6027\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">custom_font = font.Font(family=&quot;Arial&quot;, size=14, weight=&quot;bold&quot;, slant=&quot;italic&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e94\u7528\u5b57\u4f53\u5230\u63a7\u4ef6<\/strong><br \/>\u521b\u5efa\u4e00\u4e2a\u6807\u7b7e\u63a7\u4ef6\uff0c\u5e76\u5c06\u81ea\u5b9a\u4e49\u5b57\u4f53\u5e94\u7528\u5230\u8be5\u63a7\u4ef6\u4e0a\u3002\u901a\u8fc7<code>font<\/code>\u53c2\u6570\u6307\u5b9a\u5b57\u4f53\u5bf9\u8c61\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">label = tk.Label(root, text=&quot;Hello, World with Custom Font!&quot;, font=custom_font)<\/p>\n<p>label.pack(pady=20)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cTkinter\u5e94\u7528\u7a0b\u5e8f<\/strong><br \/>\u4f7f\u7528<code>mainloop()<\/code>\u65b9\u6cd5\u542f\u52a8Tkinter\u7684\u4e8b\u4ef6\u5faa\u73af\uff0c\u4f7f\u7a97\u53e3\u4fdd\u6301\u6253\u5f00\u72b6\u6001\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">root.mainloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0a\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u5728Tkinter\u4e2d\u4f7f\u7528\u81ea\u5b9a\u4e49\u5b57\u4f53\u8bbe\u7f6e\u6807\u7b7e\u7684\u6587\u672c\u6837\u5f0f\u3002\u6b64\u5916\uff0cTkinter\u8fd8\u652f\u6301\u5728\u6309\u94ae\u3001\u6587\u672c\u6846\u7b49\u5176\u4ed6\u63a7\u4ef6\u4e2d\u5e94\u7528\u5b57\u4f53\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u4e8c\u3001\u4f7f\u7528PYGAME\u8bbe\u7f6e\u5b57\u4f53<\/p>\n<\/p>\n<p><p>Pygame\u662f\u4e00\u4e2a\u8de8\u5e73\u53f0\u7684Python\u6a21\u5757\uff0c\u7528\u4e8e\u5f00\u53d1\u89c6\u9891\u6e38\u620f\uff0c\u63d0\u4f9b\u4e86\u5bf9\u5b57\u4f53\u6e32\u67d3\u7684\u652f\u6301\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521d\u59cb\u5316Pygame<\/strong><br \/>\u9996\u5148\uff0c\u9700\u8981\u5bfc\u5165<code>pygame<\/code>\u6a21\u5757\uff0c\u5e76\u8c03\u7528<code>pygame.init()<\/code>\u65b9\u6cd5\u8fdb\u884c\u521d\u59cb\u5316\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p>pygame.init()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u663e\u793a\u7a97\u53e3<\/strong><br \/>\u521b\u5efa\u4e00\u4e2aPygame\u7a97\u53e3\uff0c\u901a\u8fc7<code>pygame.display.set_mode()<\/code>\u65b9\u6cd5\u8bbe\u7f6e\u7a97\u53e3\u5927\u5c0f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">screen = pygame.display.set_mode((640, 480))<\/p>\n<p>pygame.display.set_caption(&quot;Pygame Font Example&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u52a0\u8f7d\u5b57\u4f53<\/strong><br \/>\u4f7f\u7528<code>pygame.font.Font<\/code>\u7c7b\u52a0\u8f7d\u5b57\u4f53\u6587\u4ef6\uff0c\u5e76\u6307\u5b9a\u5b57\u4f53\u5927\u5c0f\u3002\u5982\u679c\u4f7f\u7528\u7cfb\u7edf\u5b57\u4f53\uff0c\u53ef\u4ee5\u4f20\u5165<code>None<\/code>\u4f5c\u4e3a\u5b57\u4f53\u540d\u79f0\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">font = pygame.font.Font(None, 36)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6e32\u67d3\u6587\u672c<\/strong><br \/>\u4f7f\u7528<code>font.render()<\/code>\u65b9\u6cd5\u6e32\u67d3\u6587\u672c\uff0c\u6307\u5b9a\u6587\u672c\u5185\u5bb9\u3001\u53cd\u952f\u9f7f\u6548\u679c\u548c\u989c\u8272\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">text_surface = font.render(&quot;Hello, Pygame!&quot;, True, (255, 255, 255))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u6587\u672c<\/strong><br \/>\u5c06\u6e32\u67d3\u540e\u7684\u6587\u672c\u7ed8\u5236\u5230\u5c4f\u5e55\u4e0a\uff0c\u901a\u8fc7<code>blit()<\/code>\u65b9\u6cd5\u6307\u5b9a\u4f4d\u7f6e\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">screen.blit(text_surface, (100, 100))<\/p>\n<p>pygame.display.flip()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5173\u95edPygame<\/strong><br \/>\u901a\u8fc7\u4e8b\u4ef6\u5faa\u73af\u4fdd\u6301\u7a97\u53e3\u6253\u5f00\uff0c\u5e76\u5728\u5173\u95ed\u4e8b\u4ef6\u53d1\u751f\u65f6\u9000\u51faPygame\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">running = True<\/p>\n<p>while running:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == pygame.QUIT:<\/p>\n<p>            running = False<\/p>\n<p>pygame.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728Pygame\u5e94\u7528\u4e2d\u8bbe\u7f6e\u548c\u663e\u793a\u81ea\u5b9a\u4e49\u5b57\u4f53\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u4e09\u3001\u4f7f\u7528MATPLOTLIB\u8bbe\u7f6e\u5b57\u4f53<\/p>\n<\/p>\n<p><p>Matplotlib\u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u9759\u6001\u3001\u52a8\u753b\u548c\u4ea4\u4e92\u5f0f\u53ef\u89c6\u5316\u7684Python\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7<code>fontdict<\/code>\u53c2\u6570\u8bbe\u7f6e\u5b57\u4f53\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u5165Matplotlib<\/strong><br \/>\u5bfc\u5165<code>matplotlib.pyplot<\/code>\u6a21\u5757\uff0c\u901a\u5e38\u7b80\u79f0\u4e3a<code>plt<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u521b\u5efa\u56fe\u5f62\u548c\u8f74<\/strong><br \/>\u4f7f\u7528<code>plt.subplots()<\/code>\u65b9\u6cd5\u521b\u5efa\u56fe\u5f62\u548c\u8f74\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">fig, ax = plt.subplots()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b9a\u4e49\u5b57\u4f53\u5c5e\u6027<\/strong><br \/>\u901a\u8fc7\u5b57\u5178\u5b9a\u4e49\u5b57\u4f53\u5c5e\u6027\uff0c\u5305\u62ec\u5b57\u4f53\u5bb6\u65cf\u3001\u5927\u5c0f\u3001\u6837\u5f0f\u7b49\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">font_properties = {&#39;family&#39;: &#39;serif&#39;, &#39;color&#39;: &#39;darkred&#39;, &#39;weight&#39;: &#39;normal&#39;, &#39;size&#39;: 16}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u6807\u9898\u548c\u6807\u7b7e<\/strong><br \/>\u4f7f\u7528<code>set_title()<\/code>\u3001<code>set_xlabel()<\/code>\u3001<code>set_ylabel()<\/code>\u65b9\u6cd5\u8bbe\u7f6e\u6807\u9898\u548c\u6807\u7b7e\uff0c\u5e76\u5e94\u7528\u5b57\u4f53\u5c5e\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">ax.set_title(&#39;Font Example&#39;, fontdict=font_properties)<\/p>\n<p>ax.set_xlabel(&#39;X-axis&#39;, fontdict=font_properties)<\/p>\n<p>ax.set_ylabel(&#39;Y-axis&#39;, fontdict=font_properties)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u56fe\u5f62<\/strong><br \/>\u901a\u8fc7<code>plt.show()<\/code>\u65b9\u6cd5\u663e\u793a\u56fe\u5f62\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u53ef\u4ee5\u5728Matplotlib\u56fe\u5f62\u4e2d\u81ea\u5b9a\u4e49\u5b57\u4f53\u6837\u5f0f\uff0c\u4f7f\u5f97\u56fe\u5f62\u66f4\u52a0\u7f8e\u89c2\u548c\u6613\u4e8e\u9605\u8bfb\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u56db\u3001\u5b57\u4f53\u8bbe\u7f6e\u7684\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b57\u4f53\u517c\u5bb9\u6027<\/strong><br \/>\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\uff0c\u5b57\u4f53\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\uff0c\u56e0\u6b64\u5728\u9009\u62e9\u5b57\u4f53\u65f6\u9700\u8981\u8003\u8651\u8de8\u5e73\u53f0\u7684\u517c\u5bb9\u6027\u3002\u901a\u5e38\uff0c\u4f7f\u7528\u901a\u7528\u5b57\u4f53\uff08\u5982Arial\u3001Times New Roman\u7b49\uff09\u53ef\u4ee5\u63d0\u9ad8\u517c\u5bb9\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b57\u4f53\u6587\u4ef6<\/strong><br \/>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7684\u5b57\u4f53\u6587\u4ef6\u3002\u8fd9\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8def\u5f84\u52a0\u8f7d\u5b57\u4f53\u6587\u4ef6\uff0c\u4f8b\u5982\u5728Pygame\u4e2d\u52a0\u8f7d\u81ea\u5b9a\u4e49\u5b57\u4f53\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b57\u4f53\u5927\u5c0f\u548c\u6837\u5f0f<\/strong><br \/>\u5b57\u4f53\u5927\u5c0f\u548c\u6837\u5f0f\uff08\u5982\u7c97\u4f53\u3001\u659c\u4f53\uff09\u4f1a\u5f71\u54cd\u6587\u672c\u7684\u53ef\u8bfb\u6027\u548c\u7f8e\u89c2\u6027\u3002\u5728\u8bbe\u8ba1UI\u65f6\uff0c\u9700\u8981\u6839\u636e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u9009\u62e9\u5408\u9002\u7684\u5b57\u4f53\u5c5e\u6027\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u591a\u8bed\u8a00\u652f\u6301<\/strong><br \/>\u5bf9\u4e8e\u9700\u8981\u652f\u6301\u591a\u8bed\u8a00\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u786e\u4fdd\u9009\u62e9\u7684\u5b57\u4f53\u5305\u542b\u5fc5\u8981\u7684\u5b57\u7b26\u96c6\uff0c\u4ee5\u6b63\u786e\u663e\u793a\u6240\u6709\u8bed\u8a00\u7684\u6587\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u5728\u4e0d\u540c\u7684Python\u5e93\u4e2d\u8bbe\u7f6e\u5b57\u4f53\uff0c\u53ef\u4ee5\u4f7f\u5f97\u5e94\u7528\u7a0b\u5e8f\u7684\u56fe\u5f62\u754c\u9762\u548c\u53ef\u89c6\u5316\u6548\u679c\u66f4\u52a0\u4e30\u5bcc\u548c\u591a\u6837\u5316\u3002\u6839\u636e\u5177\u4f53\u7684\u9700\u6c42\u548c\u573a\u666f\u9009\u62e9\u5408\u9002\u7684\u5b57\u4f53\u8bbe\u7f6e\u65b9\u6cd5\uff0c\u662f\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u7684\u91cd\u8981\u4e00\u6b65\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u9009\u62e9\u548c\u8bbe\u7f6e\u7279\u5b9a\u5b57\u4f53\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u5e93\u6765\u8bbe\u7f6e\u5b57\u4f53\u3002\u4f8b\u5982\uff0c\u4f7f\u7528Matplotlib\u5e93\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6ercParams\u5b57\u5178\u4e2d\u7684&#39;font.family&#39;\u548c&#39;font.sans-serif&#39;\u6765\u9009\u62e9\u6240\u9700\u7684\u5b57\u4f53\u3002\u6b64\u5916\uff0cTkinter\u5e93\u4e5f\u5141\u8bb8\u901a\u8fc7\u8bbe\u7f6e<code>font<\/code>\u5c5e\u6027\u6765\u6539\u53d8\u6587\u672c\u63a7\u4ef6\u7684\u5b57\u4f53\u3002\u5177\u4f53\u7684\u8bbe\u7f6e\u65b9\u6cd5\u548c\u652f\u6301\u7684\u5b57\u4f53\u7c7b\u578b\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u76f8\u5173\u5e93\u7684\u6587\u6863\u6765\u83b7\u53d6\u3002<\/p>\n<p><strong>Python\u4e2d\u6709\u54ea\u4e9b\u5e93\u53ef\u4ee5\u7528\u6765\u5904\u7406\u5b57\u4f53\uff1f<\/strong><br \/>Python\u63d0\u4f9b\u591a\u4e2a\u5e93\u6765\u5904\u7406\u5b57\u4f53\uff0c\u4f8b\u5982Pillow\u7528\u4e8e\u56fe\u50cf\u5904\u7406\uff0cMatplotlib\u7528\u4e8e\u6570\u636e\u53ef\u89c6\u5316\uff0cTkinter\u7528\u4e8eGUI\u5e94\u7528\u3002\u8fd9\u4e9b\u5e93\u5404\u6709\u7279\u8272\uff0cPillow\u53ef\u4ee5\u8f7b\u677e\u52a0\u8f7d\u548c\u6e32\u67d3\u4e0d\u540c\u5b57\u4f53\uff0cMatplotlib\u5219\u9002\u5408\u7ed8\u5236\u5404\u79cd\u56fe\u8868\uff0cTkinter\u5219\u4e13\u6ce8\u4e8e\u521b\u5efa\u56fe\u5f62\u7528\u6237\u754c\u9762\u3002\u7528\u6237\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5e93\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u65f6\u9700\u8981\u8003\u8651\u54ea\u4e9b\u56e0\u7d20\uff1f<\/strong><br \/>\u8bbe\u7f6e\u5b57\u4f53\u65f6\u9700\u8981\u8003\u8651\u51e0\u4e2a\u56e0\u7d20\uff0c\u5305\u62ec\u5b57\u4f53\u7684\u53ef\u7528\u6027\u3001\u517c\u5bb9\u6027\u548c\u89c6\u89c9\u6548\u679c\u3002\u786e\u4fdd\u6240\u9009\u62e9\u7684\u5b57\u4f53\u5df2\u7ecf\u5b89\u88c5\u5728\u7cfb\u7edf\u4e2d\uff0c\u5426\u5219\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5b57\u4f53\u65e0\u6cd5\u663e\u793a\u3002\u517c\u5bb9\u6027\u65b9\u9762\uff0c\u67d0\u4e9b\u5b57\u4f53\u53ef\u80fd\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u8868\u73b0\u4e0d\u4e00\u81f4\u3002\u6b64\u5916\uff0c\u9009\u62e9\u9002\u5408\u5e94\u7528\u7a0b\u5e8f\u7684\u5b57\u4f53\u6837\u5f0f\u548c\u5927\u5c0f\u4e5f\u4f1a\u5f71\u54cd\u7528\u6237\u4f53\u9a8c\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8bbe\u7f6e\u5b57\u4f53\u4e3b\u8981\u6d89\u53ca\u5230\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u7f16\u7a0b\u6216\u56fe\u5f62\u7ed8\u5236\u4efb\u52a1\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecTkinter\u3001Pyg [&hellip;]","protected":false},"author":3,"featured_media":987779,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/987774"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=987774"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/987774\/revisions"}],"predecessor-version":[{"id":987780,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/987774\/revisions\/987780"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/987779"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=987774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=987774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=987774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}