【发布时间】:2021-11-13 05:06:38
【问题描述】:
破坏它的代码行:
frames = [Image.open(image) for image in glob.glob(f'{frame_folder}/*.jpg')]
frame_one = frames[0]
frame_one.save("X:\\Temp Photo Holder SolidScape Right\\resized\\progressRight.gif", format="GIF", append_images=frames,
save_all=True, optimize=True, duration=33, loop=0)
抛出的异常:
File "genGif.py", line 10
frames = [Image.open(image) for image in glob.glob(f'{frame_folder}/*.jpg')]
^
SyntaxError: invalid syntax
我用来调用 Python 的 Java:
try {
Runtime rt = Runtime.getRuntime();
String new_dir = "C:\\Users\\user\\PycharmProjects\\rightProgressGifGen\\";
rt.exec("cmd.exe /c cd \"" + new_dir + "\" & start cmd.exe /k \"python genGif.py\"");
updateProgressRightGif();
} catch (Exception e) {
updateGlobalTime();
System.out.println(e);
tweet("Exception running emailTest(). Our time is " + globalHours + ":" + globalMinutes + ":" + globalSeconds);
}
代码在 PyCharm 和 Idle 中有效,但在命令行中无效。只需要能够以某种方式从 Java 启动脚本。
【问题讨论】:
-
可能是您的系统变量指向旧版本的 Python(Python 3.6 中引入了 f 字符串)
-
@Mikey,你的问题看起来想显示命令行不能 python 3 脚本,但你的 Java 可以做到。您的 Java 代码尝试使用命令行打开 python 3 脚本。它有效。我理解正确吗?
标签: java python windows pycharm