split()方法是通过指定分隔符对字符串进行切片,然后返回分割后的字符串列表
s. split(",")
输出是:
>>>["apple","peach","banana","pear"]
s='apple,peach,banana,peach,pear'
sub='peach'
>>>s.find(sub) ##返回子串第一个字符出现的位置
6
对不起,你的问题我不知道怎么回答。凑热闹的人太多了,我们都可以接受的
['apple','peach','banana','pear']
mons = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def get_days(mon, day):
if mon == 1:
return mons[0], day
else:
count = sum(mons[:mon-1])
count = count + day
return mons[mon - 1], count
mon = int(input("请输入月份:"))
day = int(input("请输入号数:"))
result = get_days(mon, day)
print("{}月有{}天。".format(mon, result[0]))
print("{}月{}号是该年的第{}天".format(mon, day, result[1]))