我想使用字符串打印字符串,out.print但\n字符串中的字符串不起作用.
这是代码:
import java.io.PrintWriter;
public class LetterRevisited{
public static void main(String[] args)throws Exception
{
PrintWriter out = new PrintWriter("Test.txt");
out.println("This is the first line\n" +
"This is the second line" );
out.close();
}
}
Run Code Online (Sandbox Code Playgroud)
但是在保存的文件中没有创建新行,所有行都是相继的.知道如何解决这个问题吗?(除了添加out.println到所有行之外.)
编辑:我使用Windows命令提示符编译并运行代码并使用记事本打开文件.
该
plotly.io.to_image函数用于以字节对象 ( Doc ) 的形式返回图像。
我想将表示 PNG 图像的字节对象转换为 numpy 数组,以便它可以在 Folium 中用作图像叠加层。
这是一个例子:
import plotly.graph_objects as go
# Create plot
fig = go.Figure(data =
go.Contour(
z=[[10, 10.625, 12.5, 15.625, 20],
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5., 8.125, 12.5],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10]]
))
# Export byte object
img_bytes = fig.to_image(format="png",width=600, height=350)
Run Code Online (Sandbox Code Playgroud)
我尝试过使用 PIL:
from PIL import Image
img = Image.frombytes("RGB", (350,600), img_bytes)
Run Code Online (Sandbox Code Playgroud)
得到ValueError: not enough image data。
在让这个过程让我感到非常困惑之前,我从未使用过字节对象。 …