Python学习笔记(一)

sorted()函数用法详解:

https://www.notion.so/python-5e85d913a5c94c4cb31d9250af6ef6b9#89280ae9db8443fa868857dcf97fd972

print(first_name)
File "<stdin>", line 1
print(first_name)
^
IndentationError: unexpected indent

python的缩进是有语法意义的,首行的空格会引起歧义。

full_name=f"{first_name} {last_name.title}"
>>> print(full_name)
 tiory  <built-in method title of str object at 0x000001A93039C230>

f内使用title会报错

questions

  • 既然有剔除函数strip(),那么怎样才能在字符串前加入空格?
print(f" {a}")
  • 怎么在print字符串的时候制表/t
  • sorted()函数的reverse表达
sorted(name,reverse=True)
#如果把sorted当成方法处理,print(name.sorted(reverse=True))则返回:

AttributeError: 'list' object has no attribute 'sorted'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值