我使用Java和Python等组合语言与Graal VM合作。我在尝试使用context.eval()执行Python sintax读取/创建文件时遇到问题
我使用终端中的Graalpython使用此代码:
out_file = File.new("cadena.txt", "w+")
out_file.puts("write your stuff here")
out_file.close
并且可以工作,但当我尝试运行代码以使用Java读取context.eval()中的文件时:
codigoPython += "fichw = open('cadena.txt','r')";
codigoPython += "fichw.read() ";
codigoPython += "fichw.close() ";
Value filecontent = context.eval("python", codigoPython);
这给我带来了一个错误:
许可错误:(1,不允许操作,cadena.txt,无,无)
我也试着用sudo和sudo su运行它,但它给了我同样的错误。有人知道为什么会这样吗
谢谢
您需要授予上下文权限才能执行IO:
对于试验/原型设计而言,允许以下各项可能很有用:
相关问题 更多 >
编程相关推荐