Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.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“from”第4行出现连续语法错误_Python - Fatal编程技术网

python“from”第4行出现连续语法错误

python“from”第4行出现连续语法错误,python,Python,我尝试了每一个在线格式化程序,我可以找到每一个缩进的方法,但是我不断地从data.find_pending_记录中得到一个错误。这是我的密码: """Start Point""" from data.find_pending_records import FindPendingRecords from vital.vital_entry import VitalEntry if __name__ == "__main__": try: # Instantiates F

我尝试了每一个在线格式化程序,我可以找到每一个缩进的方法,但是我不断地从data.find_pending_记录中得到一个错误。这是我的密码:

"""Start Point"""

from data.find_pending_records
import FindPendingRecords
from vital.vital_entry
import VitalEntry

if __name__ == "__main__":
    try:
        # Instantiates FindPendingRecords then gets records to process
        for PENDING_RECORDS = FindPendingRecords().get_excel_data()

    # Reads excel to map data from excel to vital
    MAP_DATA = FindPendingRecords().get_mapping_data()

    # Configures Driver
    for vital
    VITAL_ENTRY = VitalEntry()

    # Start chrome and navigate to vital website
    VITAL_ENTRY.instantiate_chrome()

    # Begin processing Records
    VITAL_ENTRY.process_records(PENDING_RECORDS, MAP_DATA)

    print(PENDING_RECORDS)
    print("All done")
except Exception as exc:
    print(exc)  
Anaconda提示符中的错误信息量不大。这只是给予:

SyntaxError: invalid syntax

(base) C:\Python>python main.py
  File "main.py", line 4
    from data.find_pending_records
而且,在VisualStudio代码中,它只是同一from下的一条红色曲线,也没有任何细节

有什么想法吗?

导入需要与来自同一行:


表示该行未终止,您可以使用\

您还可以缩进以使其更具可读性

from data.find_pending_records \
    import FindPendingRecords

实际上什么是数据导入语句应该在同一行中我相信是的,这也行。关键是,如果没有相应的导入部件,from部件无法独立运行。在我看来,这个版本比一行的版本更难阅读,也不那么清晰,但它是有效的。至少第二行应该缩进,以清楚地表明它是前一行的延续。@Chris Everything有优点和缺点。如果你有有限的进口数量,那么我会喜欢你的方法,因为它是可读性和清晰。但是,如果你从一个模块中导入了100个,那么当你试图在一行中写入所有内容时,将会是一团混乱。您可以做的是缩进from语句后面的行。将更新应答如果您从单个模块有100个导入,一个常见的习惯用法是将第一个导入与from放在同一行,并将导入列表括在括号中。我看不出有什么好的理由来打破这个习惯用法,这个习惯用法没有出现在官方的风格指南中,它迫使你添加额外的语法,只是为了有效。在我看来,这不是一个好的选择,原因很多,但正如我之前所说的,它是有效的。我对这个答案投了赞成票。我只是不建议使用它。请注意,一条语句从一个模块中提供100个导入,它将只有一个导入。将单个导入与单个from保持在一起比使用n元的导入名称列表更有意义。也就是说,如果从数据中导入两个内容,下一行会是什么样子。查找\打印\记录?
from data.find_pending_records \
import FindPendingRecords
from data.find_pending_records \
    import FindPendingRecords