Python 3.6.4脚本在调试模式下工作,但在终端上运行时返回错误

2024-06-28 10:53:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我在windows10上使用了带有visualstudio代码的python3.6。 我正在使用API从SmartSheet提取数据。 这是我的密码

import smartsheet
import importlib
import supporting_tools as spt

Token = 'api_token'


sheet_id_2nd = 'sheet_id'
sheet_id_3rd = 'sheet_id'

sheet2nd = spt.read_sheet (Token, sheet_id_2nd)
sheet3rd = spt.read_sheet (Token, sheet_id_3rd)

col_map_2nd = spt.col_list (sheet2nd)
col_map_3rd = spt.col_list (sheet3rd)
print(col_map_2nd)
id_set_2nd = set()
id_set_3rd = set()
for row in sheet2nd.rows:
     Id_cell = spt.get_cell_by_column_name(row, "Row ID", col_map_2nd)
     id_set_2nd.add(Id_cell.display_value)

print(id_set_2nd)

for row in sheet3rd.rows:
     Id_cell = spt.get_cell_by_column_name(row, "Row ID", col_map_3rd)
     id_set_3rd.add(Id_cell.display_value)

print(id_set_3rd)

当我在调试模式下运行它时,它可以正常工作,但当我在终端上运行它时,它会返回此错误。我寻找了一个解决方案,看起来iPython有问题,但我不确定。有什么建议吗

"C:/Users/Jay Choi/AppData/Local/Programs/Python/Python36/python.exe" "c:/Users/Jay Choi/Desktop/New folder/main.py"
  File "<stdin>", line 1
    "C:/Users/Jay Choi/AppData/Local/Programs/Python/Python36/python.exe" "C:/Users/Jay Choi/Desktop/New folder/main.py"
    ^
SyntaxError: invalid syntax

Tags: importtokenidmapcellcoluserssheet