Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Javascript的警报框中打印python变量_Javascript_Python_Html_Alert - Fatal编程技术网

在Javascript的警报框中打印python变量

在Javascript的警报框中打印python变量,javascript,python,html,alert,Javascript,Python,Html,Alert,我无法将python变量打印到Javascript警报框中。有什么想法吗? 这是我的代码,到目前为止,我尝试了不同的变体,但似乎没有任何效果 #!/bin/python variable="hi" print "Content-type: text/html" print print '''<html> <head><title>Python Script</title></head> <meta charset="utf-8"&

我无法将python变量打印到Javascript警报框中。有什么想法吗? 这是我的代码,到目前为止,我尝试了不同的变体,但似乎没有任何效果

#!/bin/python
variable="hi"
print "Content-type: text/html"
print
print '''<html>
<head><title>Python Script</title></head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">

<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<body>
'''
print "<script>"
print "alert('Hello! I am an alert box!!  %s ');"
print "</script>"% (variable)
'''
</body>
</html>'''
#/bin/python
variable=“hi”
打印“内容类型:文本/html”
打印
打印“”'
Python脚本
'''
打印“”
打印“警报('您好!我是警报框!!%s');”
打印“”%(变量)
'''
'''
打印“警报('您好!我是警报框!!%s');”%(变量)
打印“”
您必须使用占位符对同一字符串进行替换…

print''
print '''<script>
alert('Hello! I am an alert box!!  %s ');
</script>''' % (variable)
警报('你好!我是一个警报框!!%s'); “%”(变量)
print '''<script>
alert('Hello! I am an alert box!!  %s ');
</script>''' % (variable)