1.字符串使用
>>> str="what are you doing" >>> print(str.title()) What Are You Doing使用title()函数时,可修改字符串字母的大小写,如上所述
>>> str="What Are You Doing" >>> print(str.upper()) WHAT ARE YOU DOING使用upper()函数,可以将字符串字母全部改为大写
>>> str="What Are You Doing" >>> print(str.lower()) what are you doing使用lower()函数,可以将字符串字母全部改为小写
2.拼接字符串
>>> str1="my name is" >>> str2="wu ming" >>> str3=""+str1+""+str2+"." >>> print(str3) my name iswu ming. >>> from time import ctime >>> print("new tile is"+ctime()) new tile isWed Oct 21 17:23:45 20203.将字符串拆成列表 使用split()函数,可以将字符串拆成列表
>>> str='what are you doing' >>> list=str.split() >>> list ['what', 'are', 'you', 'doing']