王重玖 发表于 2022-8-2 14:03:31

{:5_95:}

Milanero 发表于 2022-8-3 09:55:58

打卡

ctx111 发表于 2022-8-5 21:36:42

'a','b','c'.split()
('a', 'b', ['c'])
'a,b,c'.split()
['a,b,c']
'a b c'.split
<built-in method split of str object at 0x10e8ae5b0>
'a b c'.split()
['a', 'b', 'c']
'a,b,c'.split(',')
['a', 'b', 'c']
'a,b,c'.split(',',1)
['a', 'b,c']
'a,b,c'.rsplit(',',1)
['a,b', 'c']
'a\nb\nc\n'.split('\n')
['a', 'b', 'c', '']
'a\nb\nc\n.split('\n')
SyntaxError: unexpected character after line continuation character
'a\nb\nc.split('\n')
SyntaxError: unexpected character after line continuation character
'a\nb\nc'.split('\n')
['a', 'b', 'c']
'1\n2\n3'.split('\n')
['1', '2', '3']
'1\r2\r3'.split('\r')
['1', '2', '3']
'1\r2\r3'.splitlines()
['1', '2', '3']
'1\n2\n3'.splitlines()
['1', '2', '3']
'1\n2\n\r3'.splitlines()
['1', '2', '', '3']
'1\n2\r\n3'.splitlines()
['1', '2', '3']
'1\n2\r\n3\n'.splitlines()
['1', '2', '3']
'1\n2\r\n3\n'.splitlines(True)
['1\n', '2\r\n', '3\n']
'!'.join('ctx','ccc')
Traceback (most recent call last):
File "<pyshell#56>", line 1, in <module>
    '!'.join('ctx','ccc')
TypeError: str.join() takes exactly one argument (2 given)
'!'.join(['ctx','ccc'])
'ctx!ccc'

chenjinchao 发表于 2022-9-21 10:01:26

卡打

汪泽宇 发表于 2022-9-21 15:11:25

本帖最后由 汪泽宇 于 2022-9-21 15:13 编辑

这页为什么没有视频啊

chenjinchao 发表于 2022-9-21 17:29:38

卡打

lymbwx 发表于 2022-9-29 15:34:05

mark

lymbwx 发表于 2022-9-29 18:18:32

打卡

墨墨在努力吖 发表于 2022-10-4 13:57:28

>>> "www.ilovefishc.com".removeprefix("www.")
Traceback (most recent call last):
File "<pyshell#33>", line 1, in <module>
    "www.ilovefishc.com".removeprefix("www.")
AttributeError: 'str' object has no attribute 'removeprefix'
>>> "www.ilovefishc.com".removesuffix(".com")
Traceback (most recent call last):
File "<pyshell#34>", line 1, in <module>
    "www.ilovefishc.com".removesuffix(".com")
AttributeError: 'str' object has no attribute 'removesuffix'
>>>
遇到了问题,求解答,谢谢!

跟着输入结果,跟小甲鱼的不一样,报错了,上网查询,说是数据类型不对???

求解
滴滴滴~打卡{:10_266:}

墨墨在努力吖 发表于 2022-10-4 13:57:58

滴滴滴~打卡啦

墨墨在努力吖 发表于 2022-10-4 13:59:33

Moyuchen_ 发表于 2022-5-28 11:19
在使用removeprefix和removesuffix的时候python报错了,检查了一下之后我发现我的python3.8.0的字符串没有 ...

我是Python3.7.3的,使用.removeprefix()和.removesuffix()我也报错了.

墨墨在努力吖 发表于 2022-10-4 14:01:46

aBIGa 发表于 2022-4-11 12:34
>>> "www.ilovefishc.com".lstrip("wcom.")
'ilovefishc.com'                     此处wcom.四个元素分 ...

.lstrip()截取左侧wcom. 第一个那个o在il的后面,当然不能截取了呀!

墨墨在努力吖 发表于 2022-10-4 14:03:08

aBIGa 发表于 2022-4-11 12:28
>>>"www.ilovefishc.com".lstrip("wcom.")
'ilovefishc.com'
>>> "www.ilovefishc.com".rstrip("wcom.")
...

c.com都在wcom.里面

Lujiawei_CST 发表于 2022-10-26 19:57:52

完成

荔Ⅹ 发表于 2022-10-28 16:19:11

学习学习

yes120 发表于 2022-10-28 16:40:27

学习打卡

migu_sm1 发表于 2022-11-2 23:52:48

Learning...

独酌dz 发表于 2022-11-6 21:14:44

1

独酌dz 发表于 2022-11-9 15:27:27

1

独酌dz 发表于 2022-11-9 15:28:52

{:5_109:}
页: 1 [2] 3
查看完整版本: 第030讲:字符串(IV)