我是python的初学者。我已经安装了python34和xampp1.8.0并在httpd.conf作为AddHandler cgi-脚本.cgi.pl.asp.py公司 从下面的简单代码开始
#!"C:\python34\python.exe"
import cgitb
cgitb.enable()
print("Content-Type: text/html;charset=utf-8")
print ('Hello World \n')
print ( 'new world' )
print ('\n')
if ( 6 > 5) :
print ("greater")
并在本地主机中作为http://localhost/cgi-bin/example.py执行此代码
它的输出是
Hello World new world greater
字句之间没有分隔线。我错过了什么? 我需要的东西
^{pr2}$
当您打印
\n
时,它将打印一个换行符。但是,由于我假设您在浏览器中查看输出,所以HTML忽略了HTML代码中的换行。要用HTML打印换行符,必须使用break标记,它是<br />
。所以将在HTML文档中显示新行。在
\n在大多数上下文中是换行符,但是在html中,
标记用作换行符。在
对于HTML5,使用
print('<br>')
或print('<br />')
。在对于xhtml,请使用
print('<br />')
。在对于HTML4,使用
print('<br>')
。在相关问题 更多 >
编程相关推荐