python study (一)
--by chriswo
- 将变量类型转换成字符串的两种机制
字符串转换
repr(变量名):创建一个字符串,以合法的python表达式的形式来表示值;
str(变量名):把值转换为合理形式的字符串;
示例:
代码块
temp = 42
print('the temperatures is'+temp+'!!!')
temp = 42
print('the temperature is'+repr(temp)+'!!!')
temp = 42
print('the temperature is'+str(temp)+'!!!')
未完待续…
使用正则表达来寻找我们所需要的字符
import re
search = u"w"
str1 = "welcome to chriswo's csdn"
index1 = [m.start() for m in re.finditer(search,str1)]