Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

newline character php python

I have a python script (p.py)with a text like this

print "Hello"+"\n"
print "World"

I am running this file in wamp under 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"

like image 447
Ank Avatar asked Sep 08 '26 12:09

Ank


1 Answers

You will need to wrap this in <pre> tags, or use <br/>.

Try viewing something like:

<p>
This is
a test
</p>

In a web browser. You will get no newline. That's because HTML pretty much ignores newlines. You will have to use the <br/> tag for this.

like image 177
tckmn Avatar answered Sep 11 '26 03:09

tckmn