Python字符串学习

def printName():
    "Test Funciton"
    print("Hello Poem")

printName()

print(printName.__doc__)

输出

Hello Poem
Test Funciton

函数的文档字符串

字符串的操作

 


str_poem = ''' 山一程,水一程,身向榆关那畔行,夜深千帐灯。
风一更,雪一更,聒碎乡心梦不成,故园无此声。'''

str_motto = 'I wish the progress bar of my life could move more slowly that I can spare no effort to walk to the end instead of running after time'

print(str_poem[0:10])
print(str_poem[0:30])


#求字符串长度 len
len_num = len(str_motto)
print(len_num)

#切片会创建新对象
print(str_motto[2:100])
print(str_motto[100:2:-1])

#倒数的第一个字符
print(str_motto[-1])
#倒数的第三个字符
print(str_motto[-3:])

strNums = [1, 2, 3, 100, -1]
print(min(strNums))
print(max(strNums))
print(max(str_motto)) # ISCC码最大值ASCII码
print(sum(strNums))

isLower = str_motto.islower()
print(isLower)

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值