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模块,但在该目录中找不到wait方法。如何在另一个Python模块中找到实际的wait()方法定义,或者是否存在另一个包含wait()方法的Python模块?如果没有,我应该使用哪种替代方法来启动10秒延迟?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...