isalnum()"判断所有字符都是数字或者字母"
isalpha()“判断所有字符都是字母”
isdigit()“判断所有字符都是数字”
islower()“判断所有字符都是小写”
isupper()“判断所有字符都是大写”
istitle()“判断所有单词的首字母是不是大写”
isspace()“判断所有祝福都是空白字符”
返回的均是True OR False
str.upper()“把所有字符中的小写字母转换为大写字母”
str.lower()“把所有字符中的大写字母都转换为小写字母”
str.capitalize()“把第一个字母转换为大写字母,其余不变”
str.title()“把每一个单词的首字母转换为大写字母”
用法介绍
两个东西的用法类似:
print(str.title())
print(str.islower())
计算每个月的天数:
# Filename: Judge.py
# Author by : Johanan
import calendar
monthJudge= calendar.monthrange(2016,7)
print(monthJudge)
(4, 31)
返回的是一个元组,第一个元素是这个月的第一天是星期几,第二个是这个月有多少天,比如这个就代表了2016年7月1日是星期四,这个月有31天
获取退后指定天数的日期:
# Filename: date.py
# Author by : Johanan
#导入模块datetime
import datetime
#定义函数
def get():
today=datetime.date.today()
oneday=datetime.timedelta(days=int(input("请输入你想退后的天数:")))
thatday = today-oneday
return thatday
#输出
print(get())
请输入你想退后的天数:5
2016-07-21
浙公网安备 33010602011771号