python - ImportError: 无法从 'os' 导入名称 'wait' (C:\Python38\lib\os.py)
问题描述
我正在开发一个基于用户输入抓取网站的 Python 脚本。为了练习,我正在使用一个示例网站,我从中抓取数据。我遇到的问题是我使用了 wait(10) 方法。代码如下:
from os import wait
from lxml import html, etree
import requests
def select_PA_city(self):
pa_city_list = ["Philadelphia", "Pittsburgh", "Harrisburg", "Erie", "Scranton", "Allentown"]
print("The major cities in Pennsylvania are Philadelphia, Pittsburgh, Harrisburg,"
"Erie, Scranton, and Allentown.")
city_found = False
while not city_found:
pa_city = input("Select a Pennsylvania city from this list:")
for city in pa_city_list:
if pa_city == city:
print("You selected " + pa_city)
city_found = True
else:
pass
if city_found:
print("That city is one of the top 6 listed.")
else:
print("That city (" + pa_city + "} is not in the top 6. Please try again.")
os.system.wait(10)
return pa_city
现在我使用 PyCharm 社区作为我的 Python IDE,并且第一个 import 语句没有被识别。我检查了我的 c:\Python38\Lib\ 目录中的 os.py 模块,但在其中找不到等待方法。如何在另一个 Python 模块中找到实际的 wait() 方法定义,或者是否有另一个 Python 模块包含 wait() 方法?如果不是,我应该使用什么替代方法来启动 10 秒延迟?
解决方案
推荐阅读
- coronasdk - 电晕几个transition.to失相
- scala - 收集 Akka Actor 系统指标
- google-api - Google Drive API 文件权限不足错误
- javascript - 将 chart.js 用于 Polar 图表,如何为自定义宽度创建每个可见值
- firebase - dynamic_link_first_open 事件是否也会触发 first_open?
- azure-active-directory - 无法与 AzureB2C 示例中的 WebAPI 通信
- java - Dropbox API v2 用于查找已同步、移动、重命名、复制和删除的文件
- java - 如何使用 Java 10 jdk.incubator.httpclient 中的 HttpRequest.BodyPublisher?
- java - Spring在条件类的子类中注入bean
- vhdl - BIT_VECTOR 和 ARRAY OF BIT 的区别