下面是在Windows中运行的代码:
print_op = tf.print("tensors:", cut_points[0,0,:], output_stream=sys.stderr)
with tf.control_dependencies([print_op]):
return tf.identity(cut_points)
在Linux中由于反斜杠(wd, err := os.Getwd()
if err != nil {
log.Fatal(err)
}
t, err := template.ParseFiles(wd + "\\src\\html\\index.html")
)而失败
如何使此代码可跨操作系统移植?
答案 0 :(得分:1)
通常使用filepath.Join是一种方法:
path := filepath.Join("separate", "me")
但是我认为filepath.FromSlash更具可读性:
path := filepath.FromSlash("separate/me")