ImportError:无法从'os'导入名称'wait'(C:\ Python38 \ lib \ os.py)

时间:2020-08-22 21:48:09

标签: python operating-system wait

我正在研究一个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秒延迟?

0 个答案:

没有答案