资料内容:
字符串输入
之前在学习input的时候,通过它能够完成从键盘获取数据,然后保存到指定的变量中;
注意:input获取的数据,都以字符串的方式进行保存,即使输入的是数字,那么也是以字符串方式保存
demo:
userName = input('请输入用户名:')
print("用户名为:%s"%userName)
password = input('请输入密码:')
print("密码为:%s"%password)
结果:(根据输入的不同结果也不同)
请输入用户名:dongGe
用户名为: dongGe
请输入密码:haohaoxuexitiantianxiangshang
密码为: haohaoxuexitiantianxiangshang
Illegal HTML tag removed : require(["gitbook"], function(gitbook) { var config = {"toggle-chapters":{},"splitter":
{},"emphasize":{},"highlight":{},"sharing":
{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":
["facebook","google","twitter","weibo","instapaper"]},"fontsettings":
{"theme":"white","family":"sans","size":2},"livereload":{}}; gitbook.start(config); });
字符串常见操作
如有字符串 mystr = 'hello world itcast and itcastcpp' ,以下是常见的操作
Illegal HTML tag removed : find
{#illegal-html-tag-removed-find}
检测 str 是否包含在 mystr中,如果是返回开始的索引值,否则返回-1