我在使用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模块时,它会停止什么?我只希望程序导入模块并继续正常运行。
答案 0 :(得分:2)