<p>正如您的错误所述,这可能是由于没有/不良的internet连接造成的</p>
<pre><code>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
</code></pre>
<p>您可以更改/检查internet连接,然后重试。两者都不是,这是python环境的问题。
我的实施是,</p>
<pre><code>import warnings
warnings.filterwarnings("ignore")
import wikipedia
import random
value=input("Enter the words: ")
try:
m=wikipedia.search(value,3)
print(wikipedia.summary(m[0],sentences=2))
# print(p)
except wikipedia.exceptions.DisambiguationError as e:
s=random.choice(e.options)
p=wikipedia.summary(s,sentences=2)
print(p)
</code></pre>
<p>输出:</p>
<pre><code>Enter the words: programming
Program management or programme management is the process of managing several related projects, often with the intention of improving an organization's performance. In practice and in its aims, program management is often closely related to systems engineering, industrial engineering, change management, and business transformation.
</code></pre>
<p>它在googlecolab中运行良好,我的实现colab文件可以找到<a href="https://colab.research.google.com/drive/18nrqiMMUsjUNPVufOSS5cGqCMippLyrd?usp=sharing" rel="nofollow noreferrer">here</a></p>