Data_Structures in python week1

str1 = "Hello"
str2 = "there"
str3 = 'there'
bob = str1 + str2 + str3
print(bob)
Hellotherethere
x = '40'
y = int(x) +2
print(y)
42
x = 'From [email protected]'
print(x[8])
print(x[-1])
print(x[9])
print(x[14:17])
q
a
u
uct
for letter in 'banana':
    print(letter)
b
a
n
a
n
a
print(len('banana')*7)
42
greet = 'hello bob'
print(greet.upper()) # 正确语法

#print(upper(greet)) 错误的语法
#puts(greet.ucase); 错误的语法

HELLO BOB
data = 'From [email protected] Sat Jan  5 09:14:16 2008'
pos = data.find('.')
print(data[pos:pos+3])
.ma
fruit = 'banana'
'n' in fruit

True
text = "X-DSPAM-Confidence:    0.8475";

ipos = text.find(':')
print(ipos)
18
text = "X-DSPAM-Confidence:    0.8475";

ipos = text.find(':')
piece = text[ipos+5:]
value = float(piece) #以float的形式输出
print(value)
0.8475
greet = '   hello bob   '
print(greet.lstrip()) # 删除前面的空格
print(greet.rstrip()) # 删除后面的空格
print(greet.strip())  # 删除前后的空格

hello bob   
   hello bob
hello bob

你可能感兴趣的:(data_structure)