上一页 1 ··· 349 350 351 352 353 354 355 356 357 ··· 403 下一页
摘要: 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 阅读(192) 评论(0) 推荐(0)
摘要: 1、 >>> def a(x): ## 形参为x, 实参为50。 print(x * 100) >>> a(x = 50) 5000 阅读全文
posted @ 2021-03-04 10:00 小鲨鱼2018 阅读(372) 评论(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 阅读(105) 评论(0) 推荐(0)
摘要: 1、 >>> def a(): ## 创建函数 print("helloworld!") >>> a() helloworld! ## 调用函数 >>> 阅读全文
posted @ 2021-03-03 18:52 小鲨鱼2018 阅读(477) 评论(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 阅读(270) 评论(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 阅读(3508) 评论(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 阅读(518) 评论(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 阅读(307) 评论(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 阅读(687) 评论(0) 推荐(0)
摘要: 1、 >>> a = dict(zip(("a","b","c","d"),(111,222,333,444))) >>> a {'a': 111, 'b': 222, 'c': 333, 'd': 444} >>> b = a ## 假复制 >>> b {'a': 111, 'b': 222, ' 阅读全文
posted @ 2021-02-26 09:42 小鲨鱼2018 阅读(307) 评论(0) 推荐(0)
上一页 1 ··· 349 350 351 352 353 354 355 356 357 ··· 403 下一页