摘要:
tpl = "i am {name}, age {age}, really {name}".format(name="seven", age=18) print(tpl) # i am seven, age 18, really seven 必须一一对应,否则会报错 tpl = "i am {name}, age {age}, really {name}".format(**{"name": ... 阅读全文
摘要:
msg='i am %s my hobby is %s' % ('lhf','alex') # # %代表标识,固定格式 s代表传入的为字符串,该字符串可接受任何类型 # # %d ,只能接收数字 print(msg) # i am lhf my hobby is alex msg='i am %s my hobby is %s' % ('lhf',1) msg='i am %s my ... 阅读全文
摘要:
# 1.用代码实现:利用下划线将列表的'每一个元素'拼接成字符串 li=['ndfj','dlfj',12434]# 注意是将元素与元素转换为字符串之间用_拼接,而不是将每个字符串进行拼接 li=['ndfj','dlfj',12434] li[2]=str(li[2]) print('_'.join(li) ) # print:ndfj_dlfj_12434 s = '' for i in l... 阅读全文
摘要:
一、数字int(..)二、字符串replace/find/join/strip/startswith/split/upper/lower/format tempalte = "i am {name}, age : {age}" v = tempalte.format(name='alex',age= 阅读全文