以下对于字符串的相关操作,正确的输出结果是哪些选项?
A: >>> 'Life is short, you need Python.'.find('you') 15
B: >>> seq = [1, 2, 3, 4]; >>> sep = '+'; >>> sep.join(seq) '1+2+3+4'
C: >>> print '%05.3f' % math.pi 3.1416
D: >>> print 'you' in 'Life is short, you need Python.' True
A: >>> 'Life is short, you need Python.'.find('you') 15
B: >>> seq = [1, 2, 3, 4]; >>> sep = '+'; >>> sep.join(seq) '1+2+3+4'
C: >>> print '%05.3f' % math.pi 3.1416
D: >>> print 'you' in 'Life is short, you need Python.' True
举一反三
- Which output of the following choices is correct A: print('{:5.3f}'.format(math.pi)) <br>3.1416 B: 'Life is short, you need Python'. find('Life') <br>1 C: print('you' in 'Life is short, you need Python.') <br>True D: seq = [1, 2, 3, 4] <br>>>> sep = '+' <br>>>> sep.join(seq) <br>'1+2+3+4'
- 以下对于字符串的相关操作,正确的输出结果是哪些选项? A: >>> 'Life is short, you need Python.'.find('you') 15 B: >>> seq = [1, 2, 3, 4]; >>> sep = '+'; >>> sep.join(seq) '1+2+3+4' C: >>> print('{:5.3f}'.format(math.pi)) 3.1416 D: >>> print('you' in 'Life is short, you need Python.') True
- 以下对于字符串的相关操作,正确的输出结果是哪些选项? A: >;>;>;'Lifeisshort,youneedPython.'.find('you') 15 B: >;>;>;print('you'in'Lifeisshort,youneedPython.') True C: >;>;>;seq=[1,2,3,4]; >;>;>;sep='+'; >;>;>;sep.join(seq) '1+2+3+4' D: >;>;>;print('{:5.3f}'.format(math.pi)) 3.1416
- Given an English text, write a function count_len to count the frequencies of words of given length. The test string is 'Life is short, you need Python', count_len(4) will return 2. 定义函数count_len统计输入的英文文本中参数给定长度的单词出现的次数。 输入:'Life is short, you need Python.' count_len(5)输出:1 count_len(4)输出:2
- 现有字符串 st ='Life is short,you need Python' ,请使用split()方法将字符串中的Python提取出来并输出Python