字符串基本操作

已知‘星期一星期二星期三星期四星期五星期六星期日 ’,输入数字(1-7),输出相应的‘星期几’

a='星期一星期二星期三星期四星期五星期六星期日'
b=int(input('1-7:'))
print(a[3*(b-1):3*b])

 

 

输入学号,识别年级、专业、班级、序号

s=input('请输入学号:')
print('年级:'+s[0:4])
print('专业:'+s[4:8])
print('序号:'+s[-3:])

 

 

输入身份证号,识别地区、年龄、性别

s=input('请输入身份证号:')
print('地区:'+s[0:6])
print('年龄:',2017-int(s[6:10]))
print('性别:'+s[-2])

 

 

len(),eval(),+,*,in,chr(),转义\n\t\\

a='python'
print(len(a))

b=eval(input('请输入计算:'))
print(b)

a='我是帅哥!'
print(a*3)

a='hello world'
print('hello' in a)



print(chr(9807)) a='hello' b='world' print(a+'\n'+b)

 

输出全部的星座符号,以反斜线分隔。

for i in range(12):
    print(chr(9800+i),end='/')

posted @ 2017-09-15 13:10  086黄向薇  阅读(113)  评论(0)    收藏  举报