|
|
发表于 2020-2-6 12:30:55
|
显示全部楼层
本帖最后由 一个账号 于 2020-2-8 10:32 编辑
看个例子就知道了:
- Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
- Type "help", "copyright", "credits" or "license()" for more information.
- >>> def test():
- return "abc"
- >>> print(test())
- abc
- >>> test()
- 'abc'
- >>> a = test()
- >>> a
- 'abc'
- >>> print(a)
- abc
- >>> def test():
- print("abc")
-
- >>>
- >>> test()
- abc
- >>> print(test())
- abc
- None
- >>> # None 就是没有返回值
- >>> a = test()
- abc
- >>> a
- >>> print(a)
- None
- >>> def test():
- print(return "abc")
-
- SyntaxError: invalid syntax
- >>> def test():
- print(return("abc"))
-
- SyntaxError: invalid syntax
- >>> # 这种写法是错误的
- >>>
复制代码 |
|