关闭屏幕上的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
最满意答案
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
相关问答
更多-
访问Laravel中的formData(Access formData in Laravel)[2023-07-31]
您需要直接传递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, ... -
如何检查FormData?(How to inspect FormData?)[2022-07-03]
更新方法: 截至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 ... -
如何在jQuery中使用Ajax请求发送FormData对象?(How to send FormData objects with Ajax-requests in jQuery? [duplicate])[2023-04-16]
我相信你可以这样做: 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 ... -
FormData和Blob(FormData and Blob)[2022-01-30]
像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; ... -
如何修改formdata(How to modify formdata)[2023-12-19]
正如@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 = ...
-
使用FormData获取()(fetch() with FormData)[2023-03-11]
看起来问题是.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 ...