导入Webbrowser模块时,脚本等待输入

时间:2016-08-25 03:19:56

标签: python windows python-3.x windows-console

我在使用Python时遇到了一个小而烦人的问题。当我在从IDLE运行的Python脚本中导入webbrowser模块时,它完全正常。但是,如果脚本在IDLE之外运行,则导入webbrowser模块会使程序停止并等待用户输入。

我做了以下基本示例,逐步显示问题:

print('the program has started')
print('importing some random modules')
import sys
print('sys imported')
import pyperclip
print('pyperclip imported')
import logging
print('logger imported')
print('this is the line before importing the webbrowser module')
import webbrowser
print('webbrowser module imported')
print('end of demo program')

Here是我启动程序时会发生什么的屏幕截图。最后,here是我输入一些文本并按回车键后的程序截图。

在IDLE之外导入webbrowser模块时,它会停止什么?我只希望程序导入模块并继续正常运行。

1 个答案:

答案 0 :(得分:2)

发现问题了!我存储脚本的文件夹中有一个'copy.py'脚本。 webbrowser模块必须导入名为copy的模块。从目录中删除'copy.py',一切正常。