我想在 Windows 中测试我的 django 项目表单 IDLE shell。我运行以下命令
from django.template import Template, Context
t = Template('test template')
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误。
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
t = Template('test template')
File "C:\Program Files\Python26\lib\site-packages\django\template\__init__.py", line 164, in __init__
if settings.TEMPLATE_DEBUG and origin is None:
File "C:\Program Files\Python26\lib\site-packages\django\conf\__init__.py", line 28, in __getattr__
self._import_settings()
File "C:\Program Files\Python26\lib\site-packages\django\conf\__init__.py", line 59, in _import_settings
self._target = Settings(settings_module)
File "C:\Program Files\Python26\lib\site-packages\django\conf\__init__.py", line 94, in __init__
raise ImportError, "Could not import settings '%s' (Is it on …Run Code Online (Sandbox Code Playgroud) 在 bash shell 中,我可以使用“bash”或“source”手动调用脚本。我可以在 Python IDLE 的交互式 shell 中做类似的事情吗?我知道我可以转到文件>>打开模块,然后在单独的窗口中运行它,但这很麻烦。
在 Win64 上运行 Python 3.3,我在这里找到了如何在 IDLE 3.3 中添加断点,但是当我通过运行 > 运行模块(F5)运行我的模块时,它直接通过了我的断点。我错过了什么?
我在一个名为code.py. 我正在使用IDLE编辑文件。当我点击Run>Run Module我收到错误:
“IDLE 的子进程没有建立连接。IDLE 无法启动个人防火墙软件的子进程正在阻止连接。”
我使用的是 64 位 Windows 7 Ultimate,但我安装了 32 位版本的 Python 2.7。
我已经在这个网站和其他网站上寻找了一个解决方案,但他们似乎都建议删除一个叫做tkinter.py(我不知道这是什么)或关闭我的防火墙(我没有启用除了Microsoft Security Essentials这不是一个防火墙。)
#Globals
#-------------------
x_pad = 476
y_pad = 444
import ImageGrab
import os
import time
import win32api, win32con
def screenGrab():
box = (x_pad+1,y_pad+1,x_pad+641,y_pad+480)
im = ImageGrab.grab(box)
im.save(os.getcwd() + '\\full_snap__' + str(int(time.time())) +
'.png', 'PNG')
def main():
pass
if __name__ == '__main__':
main()
def leftClick():
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
print 'Click.' #completely optional. But …Run Code Online (Sandbox Code Playgroud) 我尝试IDLE从 cygwin启动,但出现以下错误:
Traceback (most recent call last):
File "/usr/bin/idle", line 5, in <module>
main()
File "/usr/lib/python2.7/idlelib/PyShell.py", line 1537, in main
root = Tk(className="Idle")
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1764, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Run Code Online (Sandbox Code Playgroud)
我可以IDLE从idle.bat文件中 启动cygstart idle.bat.
我搜索了此错误的解释,但找不到。我还在IDLEcygwin 中添加了一个环境变量。当我这样做时printenv,它显示为一个环境变量。以防万一这是问题,我尝试了两个环境变量:
idle=C:\Python27\Lib\idlelib\idle.bat
PATH = cygdrive/c/Python27/Lib/idlelib
我还安装了 cygwinIDLE包。
可能是什么问题呢?
所以,我通过互联网搜索,这是非常令人沮丧的.当我尝试搜索时,我会得到关于如何解码和编码文件的解释.但我对此并不感兴趣.我知道这是可能的,因为我能够做到这一点.我不知道发生了什么.此外,我已经尝试重新安装python.更改配置IDLE等下的选项.在我的笔记本电脑上没有任何问题.我可以做这个:
>> a = '?'
>>
>> print a
>> ?
Run Code Online (Sandbox Code Playgroud)
在我的电脑上,我得到:
>> a = '?'
>> Unsupported characters in input
Run Code Online (Sandbox Code Playgroud)
我再说一遍,我不是在谈论程序中的编码.我在谈论Python控制台,它可以在我的笔记本电脑上工作,并在以前的机器上工作.必须有一个解决这个问题的方法.
另外,看看这个:
>>> a = u'ç'
>>> a
u'\xe7'
>>> print a
ç
>>> a = u'?'
Unsupported characters in input
>>>
Run Code Online (Sandbox Code Playgroud) Python 的 IDLE 与其命令行环境之间的主要区别是什么?IDLE 看起来更好看,当然,还有某种 GUI ......
此外,IDLE 是否和 shell 一样对待?我的意思是,shell 是用户和 Python 解释器之间的中间层?
使用空闲 Python 3.4.3。这是一个脚本,它给用户一个小测验,然后计算有多少是正确的。在我的脚本运行之前,我在评论中遇到了无效的语法错误。这是评论周围的整个代码。具体评论在下面一行score = decimal.Decimal(score):
score = amountright/7*100 """this takes the amount of questions the user got right, divides it by 7 (the total number of questions), then multiplies it by 100 to get a percentage correct and stores it in the variable score"""
import decimal """this will import a function to round off the final percentage to a whole number instead of an unnecessarily long decimal"""
score = decimal.Decimal(score)
"""this redefines the score variable as some sort …Run Code Online (Sandbox Code Playgroud) 我刚从官方网站下载了最新的Python 2.7.11 64位,并将其安装到我的Windows 10中.我发现如果新的IDLE文件包含中文字符,就像你好,那么我就无法保存文件了.如果我试图多次保存它,那么新文件崩溃并消失.
我还安装了最新的python-3.5.1-amd64.exe,它没有这个问题.
怎么解决?
更多: 来自wiki页面的示例代码, https://zh.wikipedia.org/wiki/%E9%B8%AD%E5%AD%90%E7%B1%BB%E5%9E%8B
如果我在这里通过代码,StackOverflow会警告我:Body不能包含"我只是dow".为什么?
谢谢!
更多: 我找到这个配置选项,但它根本没有帮助.IDLE - > Options - > Configure IDLE - > General - > Default Source Encoding:UTF-8
我刚刚在 MacOS 上安装了最新版本的 Python (3.7.0),现在每当我向下滚动时,我的 Idle 都会崩溃。我该怎么办?
python-idle ×10
python ×8
python-2.7 ×3
python-3.x ×2
breakpoints ×1
comments ×1
cygwin ×1
django ×1
file ×1
macos ×1
shell ×1
syntax ×1
tkinter ×1
windows ×1