python - 尝试在第 71 行运行 reindent.py 时出错
问题描述
尝试从 Windows 10 命令提示符运行 reindent 命令时,出现以下错误:
C:\Users\ianpo\renpy-7.3.5-sdk\projects\test\game>python -m reindent script.rpy
Traceback (most recent call last):
File "C:\Users\ianpo\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 184, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "C:\Users\ianpo\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 154, in _get_module_details
code = loader.get_code(mod_name)
File "<frozen importlib._bootstrap_external>", line 916, in get_code
File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ianpo\AppData\Local\Programs\Python\Python38\lib\site-packages\reindent.py", line 71
except getopt.error, msg:
^
SyntaxError: invalid syntax
任何关于这里发生的事情的线索都将非常感激。我对 Python 和 Windows 很陌生,所以请像我是个傻瓜一样回答。我尝试使用 pip 重新安装并确保添加了选项标志。第七行导致错误。
def main():
import getopt
global verbose, recurse, dryrun, makebackup
try:
opts, args = getopt.getopt(sys.argv[1:], "drnvh",
["dryrun", "recurse", "nobackup", "verbose", "help"])
except getopt.error, msg:
usage(msg)
return
for o, a in opts:
if o in ('-d', '--dryrun'):
dryrun += 1
elif o in ('-r', '--recurse'):
recurse += 1
elif o in ('-n', '--nobackup'):
makebackup = False
elif o in ('-v', '--verbose'):
verbose += 1
elif o in ('-h', '--help'):
usage()
return
if not args:
r = Reindenter(sys.stdin)
r.run()
r.write(sys.stdout)
return
for arg in args:
check(arg)
解决方案
所以问题与 pip 安装的 reindent 版本过时有关,该版本与当前的 python 不兼容。如果其他人遇到同样的问题,请转到此处获取文件的最新版本。
推荐阅读
- php - 库存数量
- exception - 公用文件夹的 FindItems 上的内部服务器错误
- api - 尝试从 API 获取数据时,类型 Null 不是 int 类型的子类型错误
- azure - 如何通过 REST API、Powershell 或 Azure CLI 提取 azure 资源模板格式
- reactjs - 如何在 React 钩子的 useEffect 中避免 setState?
- ios - 无法在 Realm Studio 上查看领域文件
- python - 如何在python中解析xml字符串属性
- java - 如何在javafx中反转矩形的图像
- installation - 如何创建补丁?
- angular - 无法从 NbMenuItem 调用方法 TS 函数