資料內(nèi)容:
字符串輸入
之前在學(xué)習(xí)input的時候,通過它能夠完成從鍵盤獲取數(shù)據(jù),然后保存到指定的變量中;
注意:input獲取的數(shù)據(jù),都以字符串的方式進(jìn)行保存,即使輸入的是數(shù)字,那么也是以字符串方式保存
demo:
userName = input('請輸入用戶名:')
print("用戶名為:%s"%userName)
password = input('請輸入密碼:')
print("密碼為:%s"%password)
結(jié)果:(根據(jù)輸入的不同結(jié)果也不同)
請輸入用戶名: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