我需要一个占位符 [英] I Need A Placeholder
问题描述
我正在尝试构建一个try / except案例,我想要这样的除了
函数:
尝试:
#在这里做一些代码
var = 1#例如
除了:
#在这里什么也没做/>
唯一的问题是如果我只在except块中留下评论,我
得到一个错误,说明除了块不正确
格式化,因为它没有评论以外的内容。
所以,如果有人可以建议一些代码作为占位符放在那里
会很棒。
2008年6月26日星期四10:03:47 -0700,Ampedesign写道:
我正在尝试构建一个try / except案例,我希望得到除了
之类的函数:
尝试:
#在这里做一些代码
var = 1#例如
除了:
#什么都没有在这里
唯一的问题是如果我只在except块中留下评论,我
得到一个错误,回复说除了块是不正确
格式化,因为它没有评论以外的内容。
所以,如果有人可以建议一些代码作为占位符放在那里
这将是美妙的。
" pass"工作正常。
试试:
#做一些可以抛出异常的东西
除了:
pass
6月26日上午10:06 * am,Daniel Mahoney< d ... @ catfolks.netwrote:
< blockquote class =post_quotes>
On Thu,26 Jun 2008 10:03:47 -0700,Ampedesign写道:
我正在尝试构建一个try / except案例,我希望得到除了
之类的函数:
try:
* * *#在这里做一些代码
* * * var = 1 * * * *#例如
除了:
* * *#在这里什么都没有
唯一的问题是如果我只在except块中留下评论,我
得到一个错误,说除了块没有正确格式化,因为它没有评论以外的内容。
因此,如果有人可以建议将一些代码作为占位符放在那里
这将是美妙的。
" pass"工作正常。
试试:
* * *#做一些可以抛出异常的东西
除了:
* * *传递
谢谢。这将完美地运作。
Ampedesign写道:
我正在尝试建立一个尝试/除外case,我想要除了
之类的功能:
试试:
#在这里做一些代码
var = 1#例如
除了:
#这里什么都没有
尝试:
#在这里做一些代码
var = 1#例如
除了:
传递
Gary Herron
唯一的问题是如果我只在except块中留下评论,我
得到一个错误,说除了块不正确
格式化,因为它没有评论以外的内容。
因此,如果有人可以建议将一些代码作为占位符放在那里
那将是非常好的。
-
http://mail.python.org/mailman/listinfo/python-list
I''m trying to build a try/except case, and I want to have the except
function like such:
try:
# Do some code here
var = 1 # For example
except:
#Do nothing here
The only problem is if I leave a comment only in the except block, I
get an error back saying that the except block is not properly
formatted, since it has no content other than a comment.
So if anyone could suggest some code to put there as a placeholder
that would be wonderful.
On Thu, 26 Jun 2008 10:03:47 -0700, Ampedesign wrote:
I''m trying to build a try/except case, and I want to have the except
function like such:
try:
# Do some code here
var = 1 # For example
except:
#Do nothing here
The only problem is if I leave a comment only in the except block, I
get an error back saying that the except block is not properly
formatted, since it has no content other than a comment.
So if anyone could suggest some code to put there as a placeholder
that would be wonderful."pass" would work fine.
try:
# Do something that can throw an exception
except:
pass
On Jun 26, 10:06*am, Daniel Mahoney <d...@catfolks.netwrote:On Thu, 26 Jun 2008 10:03:47 -0700, Ampedesign wrote:I''m trying to build a try/except case, and I want to have the except
function like such:
try:
* * * # Do some code here
* * * var = 1 * * * * # For example
except:
* * * #Do nothing here
The only problem is if I leave a comment only in the except block, I
get an error back saying that the except block is not properly
formatted, since it has no content other than a comment.
So if anyone could suggest some code to put there as a placeholder
that would be wonderful.
"pass" would work fine.
try:
* * *# Do something that can throw an exception
except:
* * *passThanks. That will work perfectly.
Ampedesign wrote:I''m trying to build a try/except case, and I want to have the except
function like such:
try:
# Do some code here
var = 1 # For example
except:
#Do nothing here
try:
# Do some code here
var = 1 # For example
except:
pass
Gary Herron
The only problem is if I leave a comment only in the except block, I
get an error back saying that the except block is not properly
formatted, since it has no content other than a comment.
So if anyone could suggest some code to put there as a placeholder
that would be wonderful.
--
http://mail.python.org/mailman/listinfo/python-list
这篇关于我需要一个占位符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!