上一页 1 ··· 313 314 315 316 317 318 319 320 321 ··· 367 下一页
摘要: 1、 >>> def a(x,y,z): print(x / y + z) >>> a(10,2,4) ## 默认位置参数 9.0 >>> a(x = 2,y = 10, z = 4) ## 指定关键字参数 4.2 >>> >>> a(x = 2, y = 10,4) SyntaxError: po 阅读全文
posted @ 2021-03-04 10:54 小鲨鱼2018 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> def a(x,y): ## 函数文档 """ function: sum author: xxxx date: 2021.3.4 """ print(x + y) >>> a(40,80) 120 >>> print(a.__doc__) ## 获取函数文档 function: su 阅读全文
posted @ 2021-03-04 10:26 小鲨鱼2018 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> def a(x): ## 形参为x, 实参为50。 print(x * 100) >>> a(x = 50) 5000 阅读全文
posted @ 2021-03-04 10:00 小鲨鱼2018 阅读(354) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> def a(x): ## 单个参数 print(x,"and xiao ming are good friends!") >>> a() Traceback (most recent call last): File "<pyshell#476>", line 1, in <modul 阅读全文
posted @ 2021-03-03 22:32 小鲨鱼2018 阅读(93) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> def a(): ## 创建函数 print("helloworld!") >>> a() helloworld! ## 调用函数 >>> 阅读全文
posted @ 2021-03-03 18:52 小鲨鱼2018 阅读(457) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = {1,2,3} >>> a {1, 2, 3} >>> type(a) <class 'set'> >>> a.add(4) >>> a {1, 2, 3, 4} >>> b = frozenset({1,2,3}) ## 不可变集合 >>> b frozenset({1, 2 阅读全文
posted @ 2021-03-03 11:54 小鲨鱼2018 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 1、集合单个增加元素 >>> a = {111,222,333,444} >>> a {444, 333, 222, 111} >>> type(a) <class 'set'> >>> a.add(555) >>> a {555, 333, 111, 444, 222} >>> a.add("aa 阅读全文
posted @ 2021-03-03 11:34 小鲨鱼2018 阅读(3454) 评论(0) 推荐(0) 编辑
摘要: 1、直接创建 >>> a = {111,"aaa",222,"bbb",555} >>> a {555, 111, 'aaa', 'bbb', 222} >>> type(a) <class 'set'> 2、字符串转换 >>> a = "helloworld" >>> a 'helloworld' 阅读全文
posted @ 2021-03-03 11:25 小鲨鱼2018 阅读(490) 评论(0) 推荐(0) 编辑
摘要: 1、列表 -- (中括号 + 逗号) >>> a = ["aaa","bbb","ccc","ddd"] >>> a ['aaa', 'bbb', 'ccc', 'ddd'] >>> type(a) <class 'list'> 2、元组 -- (小括号 + 逗号) >>> a = ("a","b" 阅读全文
posted @ 2021-03-02 17:23 小鲨鱼2018 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 1、 >>> a = dict(a = 111, b = 222, c = 333, d = 444) >>> for i in reversed(a): ## 逆向输出 print(i,a[i]) d 444 c 333 b 222 a 111 2、 >>> a {'a': 111, 'b': 2 阅读全文
posted @ 2021-02-26 09:59 小鲨鱼2018 阅读(668) 评论(0) 推荐(0) 编辑
上一页 1 ··· 313 314 315 316 317 318 319 320 321 ··· 367 下一页