Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Def main():给我错误_Python - Fatal编程技术网

Python Def main():给我错误

Python Def main():给我错误,python,Python,我想定义Main,然后在源代码的末尾返回Main。 我尝试了如上所示的解决方案,但出现了语法错误。 我对Python相当陌生。您有语法错误。请尝试以下代码 def Main() import pyautogui, time import uuid import random import string import os from timeit import default_timer as timer start = timer()

我想定义Main,然后在源代码的末尾返回Main。 我尝试了如上所示的解决方案,但出现了语法错误。
我对Python相当陌生。

您有语法错误。请尝试以下代码

def Main()
    import pyautogui, time
    import uuid
    import random
    import string
    import os
    from timeit import default_timer as timer
    start = timer()
    clear = lambda: os.system('cls')
    i = 0
    a = ''
    while i < 15:
        a += random.choice(string.ascii_letters)
        i += 1
    print(email.lower())
    ...

Main()

你能显示错误吗?我猜这个错误可能是因为在def之后需要使用syntaxA冒号,比如:def main:下面的行必须缩进,否则它们不是函数的一部分。非常感谢!不客气。我编辑了代码,因为在您的代码中没有定义变量email。它将抛出一个错误:NameError:name'email'未定义您现在收到的错误消息是什么?请确保变量email已定义为某个值。
import pyautogui, time
import uuid
import random
import string
import os
from timeit import default_timer as timer
email = 'some_email@some.com'
def Main():
    start = timer()
    clear = lambda: os.system('cls')
    i = 0
    a = ''
    while i < 15:
        a += random.choice(string.ascii_letters)
        i += 1
    print(email.lower())
Main()