一箩做、定義字符串變量
1.請定義三個字符串a,b,c值分別為 I,like, python
2.請將上面三個變量合并輸出'I like python'
a='I'
b='like'
c='python'
print(a)
print(b)
print(c)
print(a,b,c)
二、定義一個變量 s=' sdghHhf '
1.請先將變量s的空白符去掉 賦值給新變量s1 打印輸出
2.請分別將s1變?yōu)槿看髮?命名s2),小寫(命名s3),打印輸出s2,s3
3.請查找s1中h最先出現(xiàn)的位置 賦值給s4 打印輸出
s=' sdghHhf '
s1=s.strip()
s2=s1.upper()
s3=s1.lower()
s4=s1.find('h')
print(s1)
print(s2)
print(s3)
print(s4)
三阱高、定義一個變量x='I {} pyhon'
請用兩種方法將x中的字符串{}修改為 like 并分別賦值給兩個變量x1,x2 打印輸出
x='I {} python'
x1=x.format('like')
x2=x.replace('{}','like')
print(x1)
print(x2)
四、定義一個變量capital='人民幣100萬元'
1.請打印一下capital的長度
2.請用python語言判斷capital是否是數(shù)字
capital='人民幣100萬元'
len_capital=len(capital)
print(len_capital)
n=capital.isdigit()
print(n)