[英]newline character php python
I have a python script (p.py)with a text like this 我有一个python脚本(p.py)与这样的文本
print "Hello"+"\n"
print "World"
I am running this file in wamp under php / apache 我在php / apache下运行这个文件
<?php
$output = system("C:\\python27\\python.exe p.py")
?>
I get the following on my browser 我在浏览器上看到以下内容
Hello World
without new line 没有新线
How do I make sure the new line character appears. 如何确保显示新的换行符。 I also tried "\\r\\n"
我也试过"\\r\\n"
You will need to wrap this in <pre>
tags, or use <br/>
. 您需要将其包装在<pre>
标签中,或使用<br/>
。
Try viewing something like: 尝试查看以下内容:
<p>
This is
a test
</p>
In a web browser. 在Web浏览器中。 You will get no newline. 你不会得到换行符。 That's because HTML pretty much ignores newlines. 这是因为HTML几乎忽略了换行符。 You will have to use the <br/>
tag for this. 您必须使用<br/>
标签。
Evidently the output is HTML. 显然输出是HTML。 If you inspect the source text of the page, you probably will see the newline. 如果您检查页面的源文本,您可能会看到换行符。
Either use <br>
or: 使用<br>
或:
<?php
header("Content-Type: text/plain");
$output = system("C:\\python27\\python.exe p.py")
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.