首页 \ 问答 \ 关闭屏幕上的Python龟错误 - 如何像计算机科学家一样思考的代码:使用Python学习3(Python turtle error on closing screen - code from How to Think Like a Computer Scientist: Learning with Python 3)

关闭屏幕上的Python龟错误 - 如何像计算机科学家一样思考的代码:使用Python学习3(Python turtle error on closing screen - code from How to Think Like a Computer Scientist: Learning with Python 3)

当我运行此代码时

import turtle
import time

def show_poly():
    try:
        win = turtle.Screen()
        tess = turtle.Turtle()
        n = int(input("How many sides do you want in your polygon?"))
        angle = 360 / n
        for i in range(n):
            tess.forward(10)
            tess.left(angle)
        time.sleep(3)
    finally:
        win.bye()

show_poly()
show_poly()
show_poly()

我得到的第一个呼叫正常工作比我得到这个错误

回溯(最近一次调用最后一次):show_poly()中的文件“/home/turte.py”,第19行

文件“/home/turte.py”,第8行,show_poly tess = turtle.Turtle()

文件“/usr/lib/python3.5/turtle.py”,第3816行,在init visible = visible中)

init self._update()中的文件“/usr/lib/python3.5/turtle.py”,第2557行

文件“/usr/lib/python3.5/turtle.py”,第2660行,在_update self._update_data()中

文件“/usr/lib/python3.5/turtle.py”,第2646行,在_update_data self.screen._incrementudc()中

_incrementudc中的文件“/usr/lib/python3.5/turtle.py”,第1292行

举起终结者turtle.Terminator

如果我理解了这个问题,即使我关闭了最后一个屏幕也无法创建新屏幕。 我运行python 3.5


when I run this code

import turtle
import time

def show_poly():
    try:
        win = turtle.Screen()
        tess = turtle.Turtle()
        n = int(input("How many sides do you want in your polygon?"))
        angle = 360 / n
        for i in range(n):
            tess.forward(10)
            tess.left(angle)
        time.sleep(3)
    finally:
        win.bye()

show_poly()
show_poly()
show_poly()

I get the first call work properly than I get this error

Traceback (most recent call last): File "/home/turte.py", line 19, in show_poly()

File "/home/turte.py", line 8, in show_poly tess = turtle.Turtle()

File "/usr/lib/python3.5/turtle.py", line 3816, in init visible=visible)

File "/usr/lib/python3.5/turtle.py", line 2557, in init self._update()

File "/usr/lib/python3.5/turtle.py", line 2660, in _update self._update_data()

File "/usr/lib/python3.5/turtle.py", line 2646, in _update_data self.screen._incrementudc()

File "/usr/lib/python3.5/turtle.py", line 1292, in _incrementudc

raise Terminator turtle.Terminator

If I understand the problem I cannot create a new screen even if I closed the last. I run python 3.5


原文:https://stackoverflow.com/questions/46630254
更新时间:2022-01-17 16:01

最满意答案

form_data.get('fielDname')提取值。 所以:

alert(form_data.get('act'))

Cautoion: .get不适用于IE,Safari和android webView


form_data.get('fielDname') extracts values. So:

alert(form_data.get('act'))

Cautoion: .get not works on IE, Safari and android webView

相关问答

更多
  • 您需要直接传递formData而不使用键作为第二个参数,并将contentType设置为false var file = e.originalEvent.dataTransfer.files[0]; var formData = new FormData(); formData.append('file', file); formData.append('_token', '{{ csrf_token() }}'); $.ajaxSetup ({ processData: false, ...
  • 更新方法: 截至2016年3月,Chrome和Firefox的最新版本现在支持使用FormData.entries()来检查FormData。 来源 。 // Create a test FormData object var formData = new FormData(); formData.append('key1', 'value1'); formData.append('key2', 'value2'); // Display the key/value pairs for (var pair ...
  • 我相信你可以这样做: var fd = new FormData(); fd.append( 'file', input.files[0] ); $.ajax({ url: 'http://example.com/script.php', data: fd, processData: false, contentType: false, type: 'POST', success: function(data){ alert(data); } }); 将pro ...
  • 像Musa所说,Chrome开发工具不显示内容。 Firefox dev工具以它为例。 要检查Chrome上的行为,我使用了一个简单的zip文件 var zip = new JSZip(); zip.file("file1", "content1"); zip.file("file2", "content2"); 我使用tcpdump来查看实际发送到服务器的内容: POST /post HTTP/1.1 Host: localhost [...] User-Agent: Mozilla/5.0 (X11; ...
  • 正如@pat建议的那样,尝试清理一下你的代码。 如果你这样做是为了学习,那么就去做,我们会尽力帮助你。 另一方面,我认为最好使用一个扩展,在一个漂亮的用户界面中处理所有这些,我推荐XUpload 使用XUpload发送附加表单数据时查看Wiki (免责声明:我是扩展的作者) We can Get extra information of formdata using:- $image_type=$_REQUEST['image_user_type'];
  • form_data.get('fielDname')提取值。 所以: alert(form_data.get('act')) Cautoion: .get不适用于IE,Safari和android webView form_data.get('fielDname') extracts values. So: alert(form_data.get('act')) Cautoion: .get not works on IE, Safari and android webView
  • 我的后端代码出错了。 以上代码完美工作。 真诚道歉的错误的职位! There was a mistake in my backend code. Above code works perfectly. Sincere apologies for the wrong post!
  • 他们是访问FormData的方式 var formData = new FormData(); formData.append("username", "Groucho"); formData.append("accountnum", 123456); console.log(formData.get("username")); console.log(formData.get("accountnum")); Their is way to access FormData var formData = ...
  • 看起来问题是.then(res => res.json(), error => error.message); JSON解析错误几乎肯定是因为您没有在响应中获得JSON。 很难说出为什么你得到了弃用警告,但它可能与你的.then()调用有关。 对于两者,对结果执行一些有用的操作,例如console.log(res)和console.log(error) 。 It looks like the problem is with .then(res => res.json(), error => error.me ...
  • 请参阅https://developer.mozilla.org/en-US/docs/Web/API/FormData#Browser_compatibility 。 它声明对于chrome,在一个标志后面支持delete() , get() , getAll() , has() , set()方法。 这意味着您需要从设置中启用对这些方法的支持(在chrome:// flags中启用实验性Web平台功能标志)。 See https://developer.mozilla.org/en-US/docs/We ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。