![](/img/trans.png)
[英]How can I get print except statement printed instead of an error below in try/except syntax in Python
[英]In Python, I can print HTML to the browser, how can I ensure that the CSS that relates to it also get “printed”
//在“ Content-type ...”声明之后...
print """<html>\
<head>
<title>Create Survey</title>
<link href="styles.css" type="text/css" rel="stylesheet">
</head>
<body>...."""
假设您使用CGI之类的内容根据Web请求“打印”文本,则应依靠您的Web服务器(例如Apache)根据CSS文件在其中的位置将内容“打印”回请求客户端。 htdocs目录。
但是,如果您只想在命令行窗口中获得一些输出,则可以...
print file('/path/to/your/file/styles.css').read()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.