Python中文
首页
教程
问答
标签
搜索
登录
注册
f = open() / works in command line but not as CGI script [python] f = 在命令行中可以运行,但在CGI脚本中无法运行 [python]
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<pre><code> #! /usr/bin/env python import htmlSplitter, htmlGlue headerContent, mainContent, sideSetup, sideContent, footerContent = htmlSplitter.split("../htdocs/bcc/register.html") mainContent = "<h1>This is another Test</h1>" sideContent = "<h2>Jonathan's here!</h2>" htmlDoc = htmlGlue.glue(headerContent, mainContent, sideSetup, sideContent, footerContent) f = open("../bcc/doctest.html", "w") f.write(htmlDoc) f.close() print("Location:../bcc/doctest.html") print </code></pre> <p>当我从命令行运行这个脚本时,它工作得非常好。但是,当它以“脚本的结尾”的时候,它给了我一个错误。我已经调试过了,如果我注释掉打开的段并写下doctest.html文档“(因此,我知道我包含的其他两个模块并不是导致问题的原因)。你知道为什么这部分代码不能作为CGI脚本工作吗?有什么我应该代替的吗?在</p> <p>注意:我在'doctest.html文档'以确保脚本具有编辑权限。在</p> <p>谢谢!在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>也许只是一个复制/粘贴错误,但你的shebang似乎是缩进的。取消插入,并尝试通过服务器上的命令行启动脚本,使用<code>./yourscript</code>(而不是<code>python yourscript</code>,因为这可能是web服务器执行脚本的方式)</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
在python3中使用Scipy pearsonr函数
5 回答
在Python3中使用scipy对多个lorentzian进行数据拟合
5 回答
在Python3中使用Script=argv
9 回答
在python3中使用selenium webdriver进行未解析的回溯
2 回答
在python3中使用selenium和phantomjs的网页截图之前如何等待?
8 回答
在Python3中使用Selenium和Requests模块从网页获取文件
5 回答
在python3中使用SIGINT终止函数
8 回答
在Python3中使用SIGTERM时,允许进程完成而不是中断
2 回答
在python3中使用smtplib发送XML内容
1 回答
在python3中使用socket库(RFCOMM模式)重新连接蓝牙设备?
4 回答
在python3中使用sounddevice和numpy编写wav文件
2 回答
在python3中使用Sqlalchemy插入MySQL查找类型错误的原因
6 回答
在python3中使用sqlite、pandas和sqlalchemy很难让rollback工作
3 回答
在python3中使用SQLite的FTS3/4
1 回答
在Python3中使用struct.calcsize()和len()有区别吗?
7 回答
在python3中使用substring函数时发生TypeError
2 回答
在Python3中使用Tkinter entry小部件写入串行设备
4 回答
在python3中使用tkinter时,如何在每次按下函数时获得运行该函数的按钮?
10 回答
在python3中使用tkinter的子帧
2 回答
在Python3中使用tryexcept块时,如何避免使用未初始化的变量?
1 回答