>>> x = "12321"
>>> "是回文数。" if x == x[::-1] else "不是回文数。"
'是回文数。'
路过
打卡
{:5_103:}
小古比鱼 发表于 2020-11-20 11:58
三天前刚花费10鱼币购买了旧版的“字符串的方法及注释”,今天又要花费10鱼币购买新版的“字符串的各种方法 ...
多学习,鱼币够用的
str = "i Love you"
>>> str.capitalize()
'I love you'
>>> str.casefold()
'i love you'
>>> str.title()
'I Love You'
>>> str.swapcase()
'I lOVE YOU'
>>> str.upper()
'I LOVE YOU'
>>> str.lower()
'i love you'
>>> s = "墨墨要努力吖~"
>>> s.center(5)
'墨墨要努力吖~'
>>> s.center(10)
' 墨墨要努力吖~'
>>> s.ljust(10)
'墨墨要努力吖~ '
>>> s.rjust(10)
' 墨墨要努力吖~'
>>> s.zfill(10)
'000墨墨要努力吖~'
>>> s.center(8)
'墨墨要努力吖~ '
>>> s.center(15)
' 墨墨要努力吖~ '
>>> t = '5201314'
>>> t.zfill(10)
'0005201314'
滴滴滴~打卡{:10_298:}
{:10_254:}
字符串我来啦
x='12321'
"是回文数。"if x==x[::-1]else"不是回文数"
'是回文数。'
x='12345'
"是回文数。"if x==x[::-1]else"不是回文数"
'不是回文数'
x="hello world"
x.capitalize()
'Hello world'
x.casefold()
'hello world'
x.title()
'Hello World'
x.upper()
'HELLO WORLD'
x.lower()
'hello world'
学习学习
学习打卡
Learning...
6
s = input("请输入一个字符串:")
res = []
for each in s:
if res and res[-1].lower() == each.lower() and res[-1] != each:
res.pop()
else:
res.append(each)
for each in res:
print(each, end='')
if res and res[-1].lower() == each.lower() and res[-1] != each:这个判断条件没看懂 那位大神帮忙解答下:
1:为什么要加 res ? 正常的应该是直接取res[-1] 进行对比就可以了
2:为什么后面要加res[-1] != each
我的理解判断条件应该是 if res[-1]==each.lower() andres[-1].lower()==each
这一节课还是比较简单的
学习打卡
好实用
{:10_256:}
复习打卡完成
{:5_101:}