s = " ssss "
print(s.strip())
a = "沙发上睡觉abcsjfa"
c = 0
for i in a:
if i>=u'\u4e00' and i<= u'\u9fa5':
c +=1
print(c)
s = "sadxsad"
d = "ADASVEASDS"
a = d.lower()
b = s.upper()
print(a)
print(b)
s = "hello,word.zhang,san"
a = s.split(",")
print(a)
ls = ["d f","h e l l o","w o r d e"]
for i in range(0,len(ls)) :
ls[i]=ls[i].replace(" ","")
print(ls)
num = input("请随意输入一个书名:")
a = len(num)
print(a)
s = "acsfwsf"
b = list(s)#转换成数组
b.sort()
c = "".join(b)
c = c[::-1]#切片
print(c)
s = "hello word"
s1 = s.split(" ")
s2 =s1[::-1]
s3 =" ".join(s2)
print(s3)
s = "呵啊的古典个数呵是否"
ls = []
for i in range (0,len(s)):
if s[i]== "呵":
ls.append(i)
print(ls)
ls = ["偷影子的人","喜羊羊与灰太狼","开心超人","从你的全世界路过","啊啊爸爸出差的的额风风光光"]
for i in range(0,len(ls)):
s = ls[i]
if len(s)>10:
s= s[0:8]
ls[i]=s
print(ls)
s = "呵呵啊的古典呵呵个数呵是否"
ls = []
for i in range (0,len(s)):
if s[i]== "呵" and s[i+1]=="呵":
ls.append(i)
print(ls)
s = input("请随意输入字符串A:")
s1 = input("请输入需要判断的字符串B:")
a = True
if s.find(s1) != -1:
a = False
if a == True:
print("字符串B不在字符串A内")
else:
print("字符串B在字符串A内")
s = input("请随意输入字符串A:")
s1 = input("请输入需要判断的字符串B:")
flag = True
for i in range(0,len(s1)):
if s.find(s1[i]) == -1:
flag = False
if flag == True:
print("字符串B的所有元素在A内")
else:
print("字符串B不是所有元素都在A内")
import string
import random
s=string.ascii_letters
s1 =""
for i in range(1,10):
s1 += random.choice(s)
print(s1)
import string
import random
s=string.ascii_letters + string.digits
s1 =""
for i in range(1,10):
s1 += random.choice(s)
print(s1)
import string
s=input("请输入判断的字符串:")
if(s.isalnum()and not s.isalpha()) and not s.isdigit():
print("字符串包含数字和字母")
else:
print("字符串并不是包含数字和字母")