目录
4.len('您好,Helen')和len("\n\t\r")的值都是多少?
5."china" in "I love china"的值是true还是false?
6."I love china".find("china")的值是多少?
3.从键盘获取交互式输入的一个人的18位的身份证号,以类似于“2001年09月12日的形式输出此人的出生日期。
2.简单题
1.字符串有哪几种表示形式:
' '," ",''' '''
,其中单引号和双引号为单行字符串,而三引号为多行字符串。''' '''也表示多行注释,开始要有,结尾也要有。 //单引号,双引号都可以进行多行注释
2.format()
方法的参数有哪些?
{}为占位符,占位符可以用来接收format()方法中的参数
1.位置匹配参数
"{} is {} years old".format ("Rose",18) 'Rose is 18 years old' "{0}is {1} years old".format ("Rose",18) 'Rose is 18 years old' "Hi,{0}!{0}is{1}years old".format("Rose",18) 'Hi,Rose!Rose is 18 years old'
2.使用键值对的关键字参数匹配
"{name}was born in {year},He is {age} years old".format (name="Rose",age= 18,year=2000) 'Rose was born in 2000,He is 18 years old'
3.索引参数
student=["Rose",18] school=("Dalian","LNNU") "{1[0]} was born in 0[0]),She is {1[1]}years old".format (school,student) 'Rose was born in Dalian,She is 18 years old'这个解释一下:你可以将上面的school和student看成两行,school为第0行,student为第1行。
1 0 1
0 0 1
这样的话会更好理解。