摘要:
1.函数文档 >>> def say(name, words): '函数定义阶段, name, words叫形参' '传递进来 name words是实参' print(name + ' say: ' + words) >>> say('itxds', 'hello') itxds say: hel 阅读全文
posted @ 2020-08-01 22:57
coder_xds
阅读(735)
评论(0)
推荐(0)
摘要:
1.函数的创建和调用 >>> def MyFirstFunction(): print('hello') >>> MyFirstFunction() hello >>> >>> def test(name): print(name) >>> test('itxds') itxds >>> def a 阅读全文
posted @ 2020-08-01 21:39
coder_xds
阅读(1289)
评论(1)
推荐(1)
摘要:
1.列表、元组和字符串的共同点 都可以通过索引得到每一个元素 默认索引值总是从0开始 可以通过分片的方法得到一个范围内的元素的集合 有很多共同的操作符(重复操作符、拼接操作符、成员关系操作符) 2.创建序列 >>> list('abcdefg') ['a', 'b', 'c', 'd', 'e', 阅读全文
posted @ 2020-08-01 16:52
coder_xds
阅读(212)
评论(0)
推荐(0)
摘要:
1.format-位置格式化 >>> '{0},{1},{2}'.format(1,2,3) '1,2,3' 当参数个数小于(Max(位置索引)+1)时,系统报错 >>> '{0},{1},{3}'.format(1,2,3) Traceback (most recent call last): F 阅读全文
posted @ 2020-08-01 16:11
coder_xds
阅读(257)
评论(0)
推荐(0)
摘要:
1.不使用系统内置方法操作字符串 >>> str = '程序员' >>> str1 = str[:1] +'(加)' + str[1:2] + '(班)' + str[2:] >>> str1 '程(加)序(班)员' 2.内置函数 capitalize() 转换首字母为大写 >>> str = 'p 阅读全文
posted @ 2020-08-01 14:25
coder_xds
阅读(156)
评论(0)
推荐(0)
摘要:
1.创建和访问元组 >>> temp = (1,2,3,4,5,6) >>> temp[1] 2 >>> temp[5:] (6,) >>> temp[2:] (3, 4, 5, 6) >>> temp2 = temp[1:] >>> temp2 (2, 3, 4, 5, 6) 元组的访问同列表一样 阅读全文
posted @ 2020-08-01 12:59
coder_xds
阅读(126)
评论(0)
推荐(0)


浙公网安备 33010602011771号