白板的微信
我认为您对全局变量、返回语句和函数感到困惑。尝试一下并阅读我的内联评论:x=3def calculateOO(y): global x x=3*ydef calculateXX(z): y=3*z return yprint(calculateOO(2))#prints None, as the function has no return statementprint(x)#prints 6, as we set x to be global in the calculateOO() function aboveprint(calculateXX(2))#prints 6, as we return the value inside the functionprint(y)#causes an error, as we did not set a global y