我想在文件中写一些东西.例如,
fo=open('C:\\Python\\readline_test.txt','a')
for i in range(3):
st='abc'+'\n'
fo.write(st)
fo.close
Run Code Online (Sandbox Code Playgroud)
然后我在IDLE中打开这个python文件,然后单击"运行模块".没有错误消息,但如果我没有退出IDLE,我发现写作不完整.如何在不退出IDLE的情况下完成文件写入?谢谢.
(我在Windows XP上使用Python 2.6.2.)
运行linux mint 13
idle-python3.2之前从终端工作过,现在却没有.从终端调用idle-python3.2会抛出下面的错误但是我可以通过双击脚本来运行Idle!
这是打破这一切的非常简单的脚本(?) http://pastebin.com/pP9An3UU FWIW,脚本似乎也不起作用(运行时没有任何反应).
这是尝试从终端运行Idle3.2时终端中的错误:
File "tkinter.py", line 2, in <module>
tk = Tk()
NameError: name 'Tk' is not defined
Run Code Online (Sandbox Code Playgroud)
这是完整的错误 http://pastebin.com/J5AfAQyV
我知道默认情况下没有安装tkinter ...但它已安装
python3-tk is already the newest version.
python3-tk set to manually installed.
Run Code Online (Sandbox Code Playgroud)
我检查了系统监视器并杀死了在后台运行的所有明显的python实例.
但是,仍然没有快乐.
这是一个错误的视频:http: //youtu.be/oCLOJR2rktI
感谢您对修复的帮助.
我注意到Python的GUI被称为Idle.另一方面,Eric Idle是Monty Python的成员.这只是巧合吗?
每当我输入以下代码时:
def in_fridge():
try:
count =fridge [wanted_food]
except KeyError:
count =0
return count
fridge ={"apples":10, "oranges":3, "milk":9}
wanted_food="apples"
in_fridge()
Run Code Online (Sandbox Code Playgroud)
进入IDLE,输出"10".
当我在代码编辑器中输入相同的代码然后按F5时,不输出任何内容.作为测试,我在代码编辑器中创建了一个新文件,输入:
print ("Hello World")
Run Code Online (Sandbox Code Playgroud)
并尽职尽责地得到了输出的结果,即从IDLE shell在新窗口中显示的hello world.
所以我很好奇为什么我在IDLE环境中显示的值而不是代码编辑器,当我输入完全相同的代码时:(
import random
gCount = 1
pChoice = ("sdq")
while gCount == 10 or pChoice == ("q"):
pChoice = input("Steal, Deal or Quit [s|d|q]?")
if pChoice != ("q"):
gCount += 1
print("Jackpot:100")
#Determing and displaying choice
if pChoice == ("s"):
print("C: Steal")
elif pChoice == ("d"):
print ("C: Deal")
#Determing and displaying computer choice
cChoice= random.randint(1,2)
if cChoice == 1:
print("Comp:Steal")
elif cChoice == 2:
print("Comp:Deal")
#Determining and displaying whether the player wins or loses, as well as scores
# for …Run Code Online (Sandbox Code Playgroud) 这是我的第一篇文章,如果我做错了什么,请原谅。所以我的问题基本上是我的标题,在哪里可以下载适用于Python 3的IDLE。
我无意中更改了IDLE Python中的默认字体..并且不记得原始字体名称...因此无法更改回原始字体.
请告诉IDLE中使用的默认字体名称..
要检查,请使用以下步骤...
进入"选项"菜单,然后选择"配置IDLE"按钮
查看当前选择的字体
谢谢你的帮助!!
在我的代码中是;
If 'Laia' in name:
Run Code Online (Sandbox Code Playgroud)
但是,即使他们输入,我如何做到这一点?LaIa 或 laiA。无论大小写(大写或小写)都是一样的。
python-idle ×8
python ×7
python-2.7 ×2
python-3.x ×2
file ×1
function ×1
python-3.2 ×1
shell ×1
tkinter ×1