PyMuPDF 1.24.4 中文文档(四)(5)

简介: PyMuPDF 1.24.4 中文文档(四)

PyMuPDF 1.24.4 中文文档(四)(4)https://developer.aliyun.com/article/1559457


如何显示来自 JSON 数据的列表

此示例使用一些 JSON 数据输入来填充故事,还包含一些视觉文本格式化,并显示如何添加链接。

文件:

  • docs/samples/json-example.py

查看示例

import pymupdf
import json
my_json =  """
[
 {
 "name" :           "Five-storied Pagoda",
 "temple" :         "Rurikō-ji",
 "founded" :        "middle Muromachi period, 1442",
 "region" :         "Yamaguchi, Yamaguchi",
 "position" :       "34.190181,131.472917"
 },
 {
 "name" :           "Founder's Hall",
 "temple" :         "Eihō-ji",
 "founded" :        "early Muromachi period",
 "region" :         "Tajimi, Gifu",
 "position" :       "35.346144,137.129189"
 },
 {
 "name" :           "Fudōdō",
 "temple" :         "Kongōbu-ji",
 "founded" :        "early Kamakura period",
 "region" :         "Kōya, Wakayama",
 "position" :       "34.213103,135.580397"
 },
 {
 "name" :           "Goeidō",
 "temple" :         "Nishi Honganji",
 "founded" :        "Edo period, 1636",
 "region" :         "Kyoto",
 "position" :       "34.991394,135.751689"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Murō-ji",
 "founded" :        "early Heian period",
 "region" :         "Uda, Nara",
 "position" :       "34.536586819357986,136.0395548452301"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Fudō-in",
 "founded" :        "late Muromachi period, 1540",
 "region" :         "Hiroshima",
 "position" :       "34.427014,132.471117"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Ninna-ji",
 "founded" :        "Momoyama period, 1613",
 "region" :         "Kyoto",
 "position" :       "35.031078,135.713811"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Mii-dera",
 "founded" :        "Momoyama period, 1599",
 "region" :         "Ōtsu, Shiga",
 "position" :       "35.013403,135.852861"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Tōshōdai-ji",
 "founded" :        "Nara period, 8th century",
 "region" :         "Nara, Nara",
 "position" :       "34.675619,135.784842"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Tō-ji",
 "founded" :        "Momoyama period, 1603",
 "region" :         "Kyoto",
 "position" :       "34.980367,135.747686"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Tōdai-ji",
 "founded" :        "middle Edo period, 1705",
 "region" :         "Nara, Nara",
 "position" :       "34.688992,135.839822"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Hōryū-ji",
 "founded" :        "Asuka period, by 693",
 "region" :         "Ikaruga, Nara",
 "position" :       "34.614317,135.734458"
 },
 {
 "name" :           "Golden Hall",
 "temple" :         "Daigo-ji",
 "founded" :        "late Heian period",
 "region" :         "Kyoto",
 "position" :       "34.951481,135.821747"
 },
 {
 "name" :           "Keigū-in Main Hall",
 "temple" :         "Kōryū-ji",
 "founded" :        "early Kamakura period, before 1251",
 "region" :         "Kyoto",
 "position" :       "35.015028,135.705425"
 },
 {
 "name" :           "Konpon-chūdō",
 "temple" :         "Enryaku-ji",
 "founded" :        "early Edo period, 1640",
 "region" :         "Ōtsu, Shiga",
 "position" :       "35.070456,135.840942"
 },
 {
 "name" :           "Korō",
 "temple" :         "Tōshōdai-ji",
 "founded" :        "early Kamakura period, 1240",
 "region" :         "Nara, Nara",
 "position" :       "34.675847,135.785069"
 },
 {
 "name" :           "Kōfūzō",
 "temple" :         "Hōryū-ji",
 "founded" :        "early Heian period",
 "region" :         "Ikaruga, Nara",
 "position" :       "34.614439,135.735428"
 },
 {
 "name" :           "Large Lecture Hall",
 "temple" :         "Hōryū-ji",
 "founded" :        "middle Heian period, 990",
 "region" :         "Ikaruga, Nara",
 "position" :       "34.614783,135.734175"
 },
 {
 "name" :           "Lecture Hall",
 "temple" :         "Zuiryū-ji",
 "founded" :        "early Edo period, 1655",
 "region" :         "Takaoka, Toyama",
 "position" :       "36.735689,137.010019"
 },
 {
 "name" :           "Lecture Hall",
 "temple" :         "Tōshōdai-ji",
 "founded" :        "Nara period, 763",
 "region" :         "Nara, Nara",
 "position" :       "34.675933,135.784842"
 },
 {
 "name" :           "Lotus Flower Gate",
 "temple" :         "Tō-ji",
 "founded" :        "early Kamakura period",
 "region" :         "Kyoto",
 "position" :       "34.980678,135.746314"
 },
 {
 "name" :           "Main Hall",
 "temple" :         "Akishinodera",
 "founded" :        "early Kamakura period",
 "region" :         "Nara, Nara",
 "position" :       "34.703769,135.776189"
 }
]
"""
# the result is a Python dictionary:
my_dict = json.loads(my_json)
MEDIABOX = pymupdf.paper_rect("letter")  # output page format: Letter
WHERE = MEDIABOX + (36, 36, -36, -36)
writer = pymupdf.DocumentWriter("json-example.pdf")  # create the writer
story = pymupdf.Story()
body = story.body
for i, entry in enumerate(my_dict):
    for attribute, value in entry.items():
        para = body.add_paragraph()
        if attribute == "position":
            para.set_fontsize(10)
            para.add_link(f"www.google.com/maps/@{value},14z")
        else:
            para.add_span()
            para.set_color("#990000")
            para.set_fontsize(14)
            para.set_bold()
            para.add_text(f"{attribute} ")
            para.add_span()
            para.set_fontsize(18)
            para.add_text(f"{value}")
    body.add_horizontal_line()
# This while condition will check a value from the Story `place` method
# for whether all content for the story has been written (0), otherwise
# more content is waiting to be written (1)
more = 1
while more:
    device = writer.begin_page(MEDIABOX)  # make new page
    more, _ = story.place(WHERE)
    story.draw(device)
    writer.end_page()  # finish page
writer.close()  # close output file
del story 

使用备用的Story.write*()函数

Story.write*() 函数提供了使用故事功能的另一种方法,无需调用代码来实现调用Story.place()Story.draw()等的循环,代价是必须提供至少一个rectfn()回调。

如何使用Story.write()进行基本布局

此脚本将其自身源代码布局到每页的四个矩形中。

文件:

  • docs/samples/story-write.py

查看示例

"""
Demo script for PyMuPDF's `Story.write()` method.
This is a way of laying out a story into a PDF document, that avoids the need
to write a loop that calls `story.place()` and `story.draw()`.
Instead just a single function call is required, albeit with a `rectfn()`
callback that returns the rectangles into which the story is placed.
"""
import html
import pymupdf
# Create html containing multiple copies of our own source code.
#
with open(__file__) as f:
    text = f.read()
text = html.escape(text)
html = f'''
<!DOCTYPE html>
<body>
<h1>Contents of {__file__}</h1>
<h2>Normal</h2>
<pre>
{text}
</pre>
<h2>Strong</h2>
<strong>
<pre>
{text}
</pre>
</strong>
<h2>Em</h2>
<em>
<pre>
{text}
</pre>
</em>
</body>
'''
def rectfn(rect_num, filled):
  '''
 We return four rectangles per page in this order:
 1 3
 2 4
 '''
    page_w = 800
    page_h = 600
    margin = 50
    rect_w = (page_w - 3*margin) / 2
    rect_h = (page_h - 3*margin) / 2
    if rect_num % 4 == 0:
        # New page.
        mediabox = pymupdf.Rect(0, 0, page_w, page_h)
    else:
        mediabox = None
    # Return one of four rects in turn.
    rect_x = margin + (rect_w+margin) * ((rect_num // 2) % 2)
    rect_y = margin + (rect_h+margin) * (rect_num % 2)
    rect = pymupdf.Rect(rect_x, rect_y, rect_x + rect_w, rect_y + rect_h)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}. Returning: rect={rect}')
    return mediabox, rect, None
story = pymupdf.Story(html, em=8)
out_path = __file__.replace('.py', '.pdf')
writer = pymupdf.DocumentWriter(out_path)
story.write(writer, rectfn)
writer.close() 
  • 如何使用Story.write_stabilized()进行迭代布局表格目录

此脚本动态创建 HTML 内容,基于具有非零.heading值的 ElementPosition 项目添加内容部分。

文档开头是内容部分,因此对内容的修改可能会更改文档其余部分的页码,从而可能导致内容部分的页码不正确。

因此,脚本使用Story.write_stabilized()重复布局,直到稳定。

文件:

  • docs/samples/story-write-stabilized.py

查看示例

"""
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized()`.
`pymupdf.Story.write_stabilized()` is similar to `pymupdf.Story.write()`,
except instead of taking a fixed html document, it does iterative layout
of dynamically-generated html content (provided by a callback) to a
`pymupdf.DocumentWriter`.
For example this allows one to add a dynamically-generated table of contents
section while ensuring that page numbers are patched up until stable.
"""
import textwrap
import pymupdf
def rectfn(rect_num, filled):
  '''
 We return one rect per page.
 '''
    rect = pymupdf.Rect(10, 20, 290, 380)
    mediabox = pymupdf.Rect(0, 0, 300, 400)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}')
    return mediabox, rect, None
def contentfn(positions):
  '''
 Returns html content, with a table of contents derived from `positions`.
 '''
    ret = ''
    ret += textwrap.dedent('''
 <!DOCTYPE html>
 <body>
 <h2>Contents</h2>
 <ul>
 ''')
    # Create table of contents with links to all <h1..6> sections in the
    # document.
    for position in positions:
        if position.heading and (position.open_close & 1):
            text = position.text if position.text else ''
            if position.id:
                ret += f"    <li><a href=\"#{position.id}\">{text}</a>\n"
            else:
                ret += f"    <li>{text}\n"
            ret += f"        <ul>\n"
            ret += f"        <li>page={position.page_num}\n"
            ret += f"        <li>depth={position.depth}\n"
            ret += f"        <li>heading={position.heading}\n"
            ret += f"        <li>id={position.id!r}\n"
            ret += f"        <li>href={position.href!r}\n"
            ret += f"        <li>rect={position.rect}\n"
            ret += f"        <li>text={text!r}\n"
            ret += f"        <li>open_close={position.open_close}\n"
            ret += f"        </ul>\n"
    ret += '</ul>\n'
    # Main content.
    ret += textwrap.dedent(f'''
 <h1>First section</h1>
 <p>Contents of first section.
 <h1>Second section</h1>
 <p>Contents of second section.
 <h2>Second section first subsection</h2>
 <p>Contents of second section first subsection.
 <h1>Third section</h1>
 <p>Contents of third section.
 </body>
 ''')
    ret = ret.strip()
    with open(__file__.replace('.py', '.html'), 'w') as f:
        f.write(ret)
    return ret;
out_path = __file__.replace('.py', '.pdf')
writer = pymupdf.DocumentWriter(out_path)
pymupdf.Story.write_stabilized(writer, contentfn, rectfn)
writer.close() 
  • 如何使用迭代布局并使用 Story.write_stabilized_links() 创建 PDF 链接

此脚本与上述“如何使用 Story.write_stabilized()”中描述的脚本类似,但生成的 PDF 还包含与原始 HTML 中的内部链接相对应的链接。

通过使用 Story.write_stabilized_links() 完成;这与 Story.write_stabilized() 稍有不同:

  • 它不接受 DocumentWriter writer 参数。
  • 它返回一个 PDF Document 实例。

这样做的原因有些复杂;例如 [DocumentWriter 并不一定是 PDF 编写器,因此不适用于特定于 PDF 的 API。]

文件:

  • docs/samples/story-write-stabilized-links.py

查看示例

"""
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized_with_links()`.
`pymupdf.Story.write_stabilized_links()` is similar to
`pymupdf.Story.write_stabilized()` except that it creates a PDF `pymupdf.Document`
that contains PDF links generated from all internal links in the original html.
"""
import textwrap
import pymupdf
def rectfn(rect_num, filled):
  '''
 We return one rect per page.
 '''
    rect = pymupdf.Rect(10, 20, 290, 380)
    mediabox = pymupdf.Rect(0, 0, 300, 400)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}')
    return mediabox, rect, None
def contentfn(positions):
  '''
 Returns html content, with a table of contents derived from `positions`.
 '''
    ret = ''
    ret += textwrap.dedent('''
 <!DOCTYPE html>
 <body>
 <h2>Contents</h2>
 <ul>
 ''')
    # Create table of contents with links to all <h1..6> sections in the
    # document.
    for position in positions:
        if position.heading and (position.open_close & 1):
            text = position.text if position.text else ''
            if position.id:
                ret += f"    <li><a href=\"#{position.id}\">{text}</a>\n"
            else:
                ret += f"    <li>{text}\n"
            ret += f"        <ul>\n"
            ret += f"        <li>page={position.page_num}\n"
            ret += f"        <li>depth={position.depth}\n"
            ret += f"        <li>heading={position.heading}\n"
            ret += f"        <li>id={position.id!r}\n"
            ret += f"        <li>href={position.href!r}\n"
            ret += f"        <li>rect={position.rect}\n"
            ret += f"        <li>text={text!r}\n"
            ret += f"        <li>open_close={position.open_close}\n"
            ret += f"        </ul>\n"
    ret += '</ul>\n'
    # Main content.
    ret += textwrap.dedent(f'''
 <h1>First section</h1>
 <p>Contents of first section.
 <ul>
 <li>External <a href="https://artifex.com/">link to https://artifex.com/</a>.
 <li><a href="#idtest">Link to IDTEST</a>.
 <li><a href="#nametest">Link to NAMETEST</a>.
 </ul>
 <h1>Second section</h1>
 <p>Contents of second section.
 <h2>Second section first subsection</h2>
 <p>Contents of second section first subsection.
 <p id="idtest">IDTEST
 <h1>Third section</h1>
 <p>Contents of third section.
 <p><a name="nametest">NAMETEST</a>.
 </body>
 ''')
    ret = ret.strip()
    with open(__file__.replace('.py', '.html'), 'w') as f:
        f.write(ret)
    return ret;
out_path = __file__.replace('.py', '.pdf')
document = pymupdf.Story.write_stabilized_with_links(contentfn, rectfn)
document.save(out_path) 

脚注

您对此页面有任何反馈吗?


此软件按原样提供,不附带任何明示或暗示的保证。此软件根据许可分发,未经授权不得复制、修改或分发。请参阅 artifex.com 获取许可信息或联系位于美国加利福尼亚州旧金山市 Mesa Street, Suite 108A 的 Artifex Software Inc. 了解更多信息。

此文档涵盖所有版本,直到 1.24.4。

### 如何使用 Story.write() 进行基本布局

此脚本将其自身的源代码多次布局到每页四个矩形中。

文件:

  • docs/samples/story-write.py

查看示例

"""
Demo script for PyMuPDF's `Story.write()` method.
This is a way of laying out a story into a PDF document, that avoids the need
to write a loop that calls `story.place()` and `story.draw()`.
Instead just a single function call is required, albeit with a `rectfn()`
callback that returns the rectangles into which the story is placed.
"""
import html
import pymupdf
# Create html containing multiple copies of our own source code.
#
with open(__file__) as f:
    text = f.read()
text = html.escape(text)
html = f'''
<!DOCTYPE html>
<body>
<h1>Contents of {__file__}</h1>
<h2>Normal</h2>
<pre>
{text}
</pre>
<h2>Strong</h2>
<strong>
<pre>
{text}
</pre>
</strong>
<h2>Em</h2>
<em>
<pre>
{text}
</pre>
</em>
</body>
'''
def rectfn(rect_num, filled):
  '''
 We return four rectangles per page in this order:
 1 3
 2 4
 '''
    page_w = 800
    page_h = 600
    margin = 50
    rect_w = (page_w - 3*margin) / 2
    rect_h = (page_h - 3*margin) / 2
    if rect_num % 4 == 0:
        # New page.
        mediabox = pymupdf.Rect(0, 0, page_w, page_h)
    else:
        mediabox = None
    # Return one of four rects in turn.
    rect_x = margin + (rect_w+margin) * ((rect_num // 2) % 2)
    rect_y = margin + (rect_h+margin) * (rect_num % 2)
    rect = pymupdf.Rect(rect_x, rect_y, rect_x + rect_w, rect_y + rect_h)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}. Returning: rect={rect}')
    return mediabox, rect, None
story = pymupdf.Story(html, em=8)
out_path = __file__.replace('.py', '.pdf')
writer = pymupdf.DocumentWriter(out_path)
story.write(writer, rectfn)
writer.close() 

如何为目录创建迭代布局,并使用 Story.write_stabilized()

此脚本动态创建 HTML 内容,基于具有非零 .heading 值的 ElementPosition 项添加内容部分。

内容部分位于文档开头,因此对内容的修改可能会改变文档其余部分的页码,进而导致内容部分的页码不正确。

因此,脚本使用 Story.write_stabilized() 来重复布局,直到稳定为止。

文件:

  • docs/samples/story-write-stabilized.py

查看示例

"""
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized()`.
`pymupdf.Story.write_stabilized()` is similar to `pymupdf.Story.write()`,
except instead of taking a fixed html document, it does iterative layout
of dynamically-generated html content (provided by a callback) to a
`pymupdf.DocumentWriter`.
For example this allows one to add a dynamically-generated table of contents
section while ensuring that page numbers are patched up until stable.
"""
import textwrap
import pymupdf
def rectfn(rect_num, filled):
  '''
 We return one rect per page.
 '''
    rect = pymupdf.Rect(10, 20, 290, 380)
    mediabox = pymupdf.Rect(0, 0, 300, 400)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}')
    return mediabox, rect, None
def contentfn(positions):
  '''
 Returns html content, with a table of contents derived from `positions`.
 '''
    ret = ''
    ret += textwrap.dedent('''
 <!DOCTYPE html>
 <body>
 <h2>Contents</h2>
 <ul>
 ''')
    # Create table of contents with links to all <h1..6> sections in the
    # document.
    for position in positions:
        if position.heading and (position.open_close & 1):
            text = position.text if position.text else ''
            if position.id:
                ret += f"    <li><a href=\"#{position.id}\">{text}</a>\n"
            else:
                ret += f"    <li>{text}\n"
            ret += f"        <ul>\n"
            ret += f"        <li>page={position.page_num}\n"
            ret += f"        <li>depth={position.depth}\n"
            ret += f"        <li>heading={position.heading}\n"
            ret += f"        <li>id={position.id!r}\n"
            ret += f"        <li>href={position.href!r}\n"
            ret += f"        <li>rect={position.rect}\n"
            ret += f"        <li>text={text!r}\n"
            ret += f"        <li>open_close={position.open_close}\n"
            ret += f"        </ul>\n"
    ret += '</ul>\n'
    # Main content.
    ret += textwrap.dedent(f'''
 <h1>First section</h1>
 <p>Contents of first section.
 <h1>Second section</h1>
 <p>Contents of second section.
 <h2>Second section first subsection</h2>
 <p>Contents of second section first subsection.
 <h1>Third section</h1>
 <p>Contents of third section.
 </body>
 ''')
    ret = ret.strip()
    with open(__file__.replace('.py', '.html'), 'w') as f:
        f.write(ret)
    return ret;
out_path = __file__.replace('.py', '.pdf')
writer = pymupdf.DocumentWriter(out_path)
pymupdf.Story.write_stabilized(writer, contentfn, rectfn)
writer.close() 

如何使用迭代布局并使用 Story.write_stabilized_links() 创建 PDF 链接

此脚本类似于“如何使用Story.write_stabilized()”中描述的脚本,但生成的 PDF 还包含与原始 HTML 中的内部链接相对应的链接。

这是通过使用Story.write_stabilized_links()完成的;这与Story.write_stabilized()略有不同:

  • 它不需要 DocumentWriter writer 参数。
  • 它返回一个 PDF Document 实例。

其中原因有些复杂;例如[DocumentWriter 不一定是 PDF 编写器,因此在 PDF 特定的 API 中并不适用。]

文件:

  • docs/samples/story-write-stabilized-links.py

查看示例

"""
Demo script for PyMuPDF's `pymupdf.Story.write_stabilized_with_links()`.
`pymupdf.Story.write_stabilized_links()` is similar to
`pymupdf.Story.write_stabilized()` except that it creates a PDF `pymupdf.Document`
that contains PDF links generated from all internal links in the original html.
"""
import textwrap
import pymupdf
def rectfn(rect_num, filled):
  '''
 We return one rect per page.
 '''
    rect = pymupdf.Rect(10, 20, 290, 380)
    mediabox = pymupdf.Rect(0, 0, 300, 400)
    #print(f'rectfn(): rect_num={rect_num} filled={filled}')
    return mediabox, rect, None
def contentfn(positions):
  '''
 Returns html content, with a table of contents derived from `positions`.
 '''
    ret = ''
    ret += textwrap.dedent('''
 <!DOCTYPE html>
 <body>
 <h2>Contents</h2>
 <ul>
 ''')
    # Create table of contents with links to all <h1..6> sections in the
    # document.
    for position in positions:
        if position.heading and (position.open_close & 1):
            text = position.text if position.text else ''
            if position.id:
                ret += f"    <li><a href=\"#{position.id}\">{text}</a>\n"
            else:
                ret += f"    <li>{text}\n"
            ret += f"        <ul>\n"
            ret += f"        <li>page={position.page_num}\n"
            ret += f"        <li>depth={position.depth}\n"
            ret += f"        <li>heading={position.heading}\n"
            ret += f"        <li>id={position.id!r}\n"
            ret += f"        <li>href={position.href!r}\n"
            ret += f"        <li>rect={position.rect}\n"
            ret += f"        <li>text={text!r}\n"
            ret += f"        <li>open_close={position.open_close}\n"
            ret += f"        </ul>\n"
    ret += '</ul>\n'
    # Main content.
    ret += textwrap.dedent(f'''
 <h1>First section</h1>
 <p>Contents of first section.
 <ul>
 <li>External <a href="https://artifex.com/">link to https://artifex.com/</a>.
 <li><a href="#idtest">Link to IDTEST</a>.
 <li><a href="#nametest">Link to NAMETEST</a>.
 </ul>
 <h1>Second section</h1>
 <p>Contents of second section.
 <h2>Second section first subsection</h2>
 <p>Contents of second section first subsection.
 <p id="idtest">IDTEST
 <h1>Third section</h1>
 <p>Contents of third section.
 <p><a name="nametest">NAMETEST</a>.
 </body>
 ''')
    ret = ret.strip()
    with open(__file__.replace('.py', '.html'), 'w') as f:
        f.write(ret)
    return ret;
out_path = __file__.replace('.py', '.pdf')
document = pymupdf.Story.write_stabilized_with_links(contentfn, rectfn)
document.save(out_path) 

脚注

对本页面有任何反馈吗?


该软件按原样提供,不提供任何明示或暗示的担保。该软件在许可下分发,未经许可明确授权,不得复制、修改或分发。有关详细信息,请参阅artifex.com,或联系美国旧金山 CA 94129 Mesa 街 39 号 108A 套房的 Artifex Software Inc.。

此文档涵盖所有版本直到 1.24.4。


相关文章
|
小程序 网络安全 Windows
swoole(二)ws与wss的区别
关于ws与wss的区别这里简单的说一下我目前的见解。 如果你有更多的见解欢迎在下方留言讨论。 最简单的理解就是: 服务器上服务端用的是:websocket协议(支持客户端的ws访问) 服务器上服务端用的是:websocket协议+TLS(支持客户端的wss访问) 客户端上用的是: ws协议或者wss协议 Wss与ws其实就和http与https的关系,wss需要验证域名证书,ws不需要验证域名证书。 这个其实都不重要。我们在开发的时候关系不是很大。 下边的才是我要说的重点: Ws链接可以使用IP+端口号的形式访问。 Wss链接只能使用域名的形式访问,因为服务器端需要通过域名来找对应的ssl证书
1607 0
|
6月前
|
机器学习/深度学习 人工智能 自然语言处理
【干货】软件测试转 AI 测试开发?这些面试题你必须知道!
想转型AI测试开发?掌握AI/ML基础、模型评估、自动化测试与CI/CD全流程是关键!我们整理了面试必备题库,并推出【人工智能测试开发训练营】,助你系统构建AI测试能力体系,提升面试竞争力,实现职业进阶。
|
8月前
|
人工智能 并行计算 算法
三相PWM整流器有限集模型预测电流控制Simulink仿真模型
三相PWM整流器有限集模型预测电流控制Simulink仿真模型
248 0
|
人工智能 前端开发
大模型体验体验报告:OpenAI-O1内置思维链和多个llm组合出的COT有啥区别?传统道家理论+中学生物理奥赛题测试,名不虚传还是名副其实?
一个月前,o1发布时,虽然让人提前体验,但自己并未进行测试。近期终于有机会使用,却仍忘记第一时间测试。本文通过两个测试案例展示了o1的强大能力:一是关于丹田及练气的详细解答,二是解决一道复杂的中学生物理奥赛题。o1的知识面广泛、推理迅速,令人印象深刻。未来,或许可以通过赋予o1更多能力,使其在更多领域发挥作用。如果你有好的测试题,欢迎留言,一起探索o1的潜力。
744 1
|
机器学习/深度学习 算法 搜索推荐
"震撼揭秘!阿里云AIGC智能图像识别:黑科技如何颠覆你的视界,让图像识别秒变超能力,生活工作全面革新!"
【8月更文挑战第12天】在数字化浪潮中,图像数据激增,高效准确处理成为关键。阿里云智能图像识别服务(AIGC)应运而生,依托深度学习与计算机视觉技术,实现图像特征精确提取与理解。通过大规模数据训练及优化算法,AIGC在图像分类、目标检测等方面表现出色。其应用场景广泛,从电商的商品识别到内容安全审核,再到智能交通和医疗影像分析,均展现出巨大潜力。示例代码展示了AIGC图像生成的基本流程,彰显其技术实力与未来前景。
597 1
|
小程序 Ubuntu Linux
PXE高效批量网络装机
PXE高效批量网络装机
|
XML 存储 数据安全/隐私保护
PyMuPDF 1.24.4 中文文档(五)(3)
PyMuPDF 1.24.4 中文文档(五)
402 0
|
存储 文字识别 Python
PyMuPDF 1.24.4 中文文档(五)(5)
PyMuPDF 1.24.4 中文文档(五)
642 0
|
XML API 数据安全/隐私保护
PyMuPDF 1.24.4 中文文档(七)(1)
PyMuPDF 1.24.4 中文文档(七)
316 0
|
存储 分布式计算 Hadoop
大数据存储技术(1)—— Hadoop简介及安装配置
大数据存储技术(1)—— Hadoop简介及安装配置

热门文章

最新文章