[英]combining two HTML codes in python
I have the following two scripts written in python.I run them in IPython notebook. 我有以下两个用python编写的脚本。我在IPython笔记本中运行它们。 When i call Textbox1 and Texbox2 in different cells, I see both the boxes. 当我在不同的单元格中调用Textbox1和Texbox2时,我会看到两个框。 However, i want these textboxes to be seen in an external HTML file. 但是,我希望在外部HTML文件中看到这些文本框。 How do i combine and send this to HTML through python. 我如何组合并通过python将其发送到HTML。
Textbox1="""
<!DOCTYPE html>
<html>
<head>
<script>
function retrieve(id) {
var txtbox = document.getElementById(id);
value = txtbox.value;
}
</script>
</head>
<body>
<input type="text" size="4" style="width: 100px;" value="Enter Email" name="txt" id="txt"></input>
<input type="button" value="Submit" onclick="retrieve('txt');"/
</body>
</html>
"""`
Textbox2="""
<!DOCTYPE html>
<html>
<head>
<script>
function retrieve(id) {
var txtbox = document.getElementById(id);
value = txtbox.value;
}
</script>
</head>
<body>
<input type="text" size="4" style="width: 100px;" value="Enter Password" name="txt" id="txt"></input>
<input type="button" value="Submit" onclick="retrieve('txt');"/
</body>
</html>
"""`
I use from IPython.display import HTML
to see HTML output in the notebook 我使用from IPython.display import HTML
来查看笔记本中的HTML输出
Combine the two boxes in one HTML string first, something like (will need formatting I guess): 首先将两个框组合在一个HTML字符串中,类似于(我猜需要格式化):
Textbox1and2="""
<!DOCTYPE html>
<html>
<head>
<script>
function retrieve(id) {
var txtbox = document.getElementById(id);
value = txtbox.value;
}
</script>
</head>
<body>
<input type="text" size="4" style="width: 100px;" value="Enter Email" name="txt" id="txt"></input>
<input type="button" value="Submit" onclick="retrieve('txt');"/
<input type="text" size="4" style="width: 100px;" value="Enter Password" name="txt" id="txt"></input>
<input type="button" value="Submit" onclick="retrieve('txt');"/
</body>
</html>
"""
Then you can do whatever you want with it, modify it further,print it with HTML() or save to a file, etc. 然后你可以随心所欲地做任何事情,进一步修改,用HTML()打印或保存到文件等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.