我正在学习Python,只是有这个问题.它可能没有实际价值,我问这个可能是因为迂腐的好奇心.
我有一个功能:
def f():
x = 12 #this is a local variable
global x #this is a global I declared before
x = 14 #changes global x
<How can I return the local x?>
Run Code Online (Sandbox Code Playgroud)
我知道这很难看,我确实得到了一个语法警告.只是想知道如何"取回"我的局部变量.
谢谢大家.