Python 函数中展示变量值:使用 print 函数
可以使用 print 函数来展示调用函数中某一变量的值。例如:
def example_function(x):
y = x + 2
print('The value of y is:', y)
example_function(3)
输出结果为:
The value of y is: 5
在函数中使用 print 语句可以将变量的值打印出来,方便调试和理解代码。
原文地址: https://www.cveoy.top/t/topic/oJSs 著作权归作者所有。请勿转载和采集!