0
A
回答
4
的功能和调用的功能外内的通话是完全独立的变量。你必须通过参数列表来传递。
call = 'Duster'
def text(call):
print(call)
text(call)
其实,你可以使用一个全球变量,但请避免这些。
为了说明这一点更好,移动你的主程序线一起,改变了名称:
def text(phrase):
print(phrase)
name = 'Duster'
text(name)
另外,两条线的主程序可以只是一条线:
text('Duster')
1
由于范围限定,名称为call
的参数优先于名为call
的变量,所以不起作用。
你可以使用你的代码,只是将最后一行
text(call)
或者你可以直接使用的变量,而不是一个参数
call = 'Duster'
def text():
print(call)
text()
使这项工作
相关问题
- 1. 如何将参数传递给函数?
- 2. 如何将参数传递给传递给mapPartitions的函数?
- 3. 将数组传递给函数参数
- 4. 如何参数传递给javascript函数
- 5. 如何参数传递给jQuery函数
- 6. 参数传递给函数
- 7. 参数传递给函数
- 8. 将bash函数参数传递给emacs
- 9. 将参数传递给比较函数?
- 10. 将多个参数传递给函数
- 11. 将参数传递给JQuery函数
- 12. 将参数传递给函数指针
- 13. javascript/d3 - 将参数传递给函数
- 14. 将参数传递给a4j:函数
- 15. 将参数传递给函数
- 16. 将参数传递给函数?
- 17. VBScript:将参数传递给函数
- 18. Haskell - 将参数传递给map函数?
- 19. 将参数传递给Compose的函数?
- 20. 将参数传递给函数引用?
- 21. 将参数传递给AsyncCallback函数?
- 22. 将宏参数传递给宏函数
- 23. 将参数传递给EventListener函数
- 24. 将参数传递给回调函数
- 25. python Tkinter:将参数传递给函数
- 26. 将参数传递给window.onload函数
- 27. 将参数传递给jQuery函数
- 28. 将参数传递给jQuery函数
- 29. jquery - 将参数传递给函数
- 30. 将参数传递给jQuery函数