python3数学建模基础(六)字符串选择性条件拼接
本文适合有python3的random库基础的读者。
你需要:①Python IDLE 3.x
②random库
#作者
#生姜用户
import random as rd
people = ['He','She']
person = rd.sample(people,1)
be = '_am_is_are'
var1 = 'cool'
var2 = 'beautiful'
article = 'a'
boy_or_girl = '_boy_gril'
var3 = ""
person = var3.join(person)
if person == 'He' :
be=be[4:6]
var4=var1
boy_or_girl = boy_or_girl[1:4]
elif person == 'She' :
be=be[4:6]
var4=var2
boy_or_girl = boy_or_girl[5:9]
print (person+' '+be+' '+article[0]+' '+var4+' '+boy_or_girl+'\n')
随机出现
- He is a cool boy
- She is a beautiful girl
喜欢的朋友记得点赞关注哟