当我输入以下代码时,PyCharm说" Expression可以进一步简化"。这个陈述的简化版本是什么?
protected void chgcontrybtn_Click(object sender, EventArgs e)
{
if (Request.Cookies["countryCookies"] != null)
{
Response.Cookies["countryCookies"].Expires = DateTime.Now.AddDays(-1);//to remove cookies
Response.Redirect("Index.aspx");
}
else if (Request.Cookies["Location"] != null)
{
Response.Cookies["Location"].Expires = DateTime.Now.AddDays(-1);
Response.Redirect("Index.aspx");
}
}

答案 0 :(得分:8)
空列表评估为假,所以你也可以这样做,这就是PyCharm可能会谈到的:
int main() {
vector<GLfloat> targetVector;
targetVector.reserve(772538368); //Attempt2 to reserve. Also tried resize()
vector<vector<vector<GLshort>>> my3DimensionalData;
//build my3DimensionalData //no problem here.
//targetVector.reserve(772538368); //Attempt1 to reserve.
for (GLint rowIndex = 0; rowIndex < numberOfRows; rowIndex++)
{
for (GLint colIndex = 0; colIndex < numberOfCols; colIndex++)
{
for (GLint depthIndex = 0; depthIndex < numberOfDepths; depthIndex++)
{
//perform gymnastic here on my3DimensionalData and get data.
/*initially I was getting bad_alloc while pushing back
*elements in the following block.
*This led to Attempt1 and Attempt2 as shown above.
*/
targetVector.push_back(data1);
targetVector.push_back(data2);
...
targetVector.push_back(data7);
}
}
}
}
有一些副作用,因为上面的代码会返回&#34;是的!&#34;每当列表为if not listA:
return "yes!"
时,空字符串(False
),""
,空字典(None
),空集({}
)以及任何内容否则python会把它视为假的