python - 如何解决在本地运行我的 python 代码?
问题描述
我已经安装了 python 3.7 版本。当我在命令中运行时,它的效果很好。但是当我尝试运行 http.server 8000 然后浏览 url 然后只显示我的 index.py 代码而不是像网页那样运行。
对此有任何想法。
我确实更改了 httpd.cong 文件 1。
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
- 添加
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm \
default.php default.pl default.cgi default.asp default.shtml default.html default.htm \
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
也请检查我的代码
#!C:\Users\admin\AppData\Local\Programs\Python\Python37\python.exe
print('sarvesh')
#print(mycursor.rowcount, "record inserted.")
所以请告诉我。
解决方案
您是否尝试放入 cgi-bin 文件夹?你能测试一下以确保你的安装没问题吗?你在使用任何放大器吗?( xampp, wamp)
推荐阅读
- ios - Check if an imageView is empty
- java - Jackson 如何自动反序列化 java.nio.file.Path?
- events - 如何让我的 Flutter 应用仅在需要时生成数字?
- swift - 将视频 url 定义为班级中的 uiview
- python - Matplotlib - 如何防止图形回溯
- symfony - 如何使用 SonataAdmin 将管理员特定区域保护到特定角色
- typescript - 此模块的自定义类型的正确文件夹结构是什么?
- r - 在 r (windows) 中找到具有递归限制的字符串中的 JSON
- prolog - 在 PROLOG 中解决即时精神错乱,但我总是得到“不”
- python - 从applescript调用虚拟环境的python文件