小编Dev*_*ani的帖子

唯一导入*仅允许在模块级别

我正在制作一个实用程序,其中内置了多个程序,但我对程序进行了一些更改,以便在用户提示时重新运行,然后由于某种原因,我面临错误

import * only allowed at module level
Run Code Online (Sandbox Code Playgroud)

这是我的代码

def main():
    
    import os
    import sys
    import time
    import pywhatkit as whatsapp
    from speedtest import Speedtest
    from tkinter import *
    from tkinter import messagebox
    from os import listdir
    from PIL import Image

    print("*"*30)
    print("Utility Build v1: Starting")
    print("*"*30)

    time.sleep(3)

    print("NOTE: Before using this program for repairing corrupted disk, please locate this utility .py file into the corrupted storage. Thanks")

    time.sleep(3)

    print("*"*30)
    print("*"*30)
    print("Commands: Choose by inputting allocated number")

    print("Utility 1: Speed …
Run Code Online (Sandbox Code Playgroud)

python syntax-error python-import

3
推荐指数
1
解决办法
3503
查看次数

标签 统计

python ×1

python-import ×1

syntax-error ×1