赞
踩
lower() #得到小写格式字符串
upper() #得到大写格式字符串
capitalize() #得到首字母大写格式
title() #得到每个单词首字母大写格式
swapcase() #得到大小写互换格式
ord()/chr() #ASCII<->字符
def strbyline(s,line=1):
# 当字符串不能被行数整除时,在末尾用空格补齐
if len(s)%line:
s = s + ' '*(len(s)%line+1)
# num表示每行输出的字符数
num = len(s) // line
for i in range(0,len(s)+1,num):
print(s[i-num:i])
strbyline('I want to eat some food! But I cannot find any.',2)
I want to eat some food!
But I cannot find any.
def reversetext(lower=1,upper=1000):
lst=[]
for i in range(lower,upper):
s = str(i)
if s == s[::-1]:
lst.append(i)
return lst
reversetext(100,200)
[101, 111, 121, 131, 141, 151, 161, 171, 181, 191]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。