python - 在 Python 中,我可以将 HTML 打印到浏览器,我如何确保与其相关的 CSS 也得到 "printed"

标签 python html css browser

//在“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()

关于python - 在 Python 中,我可以将 HTML 打印到浏览器,我如何确保与其相关的 CSS 也得到 "printed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22828355/

相关文章:

python - 使用 pandas.date_range 和 pandas.reindex python 填充时间序列数据中的缺失点

python - 无法再导入 xgboost

html - 无法找到声明此颜色的位置

javascript - jquery 数据表 - 为 select.className 应用值未按预期工作

css - Base64_encode 中的 24 位 Alpha channel

python - 如何在pyodbc下将datetime.time返回类型更改为字符串?

Python - 查找同时在 string1 和 string2 中找到的字符数

php - 选择与下拉列表中显示的值不同的值。 (PHP 和 MySQL)

css - 带有 div 的 HTML CSS 网格 3x3

html - nth-child 从多类 div 中选择错误的元素