python初學(1)字符串




1、字符串的形式 :
    單引號 '' 三單引號 ''' '''
    雙引號 "" 三雙引號 """ """
(1)爲什麼要設定單雙引號?
防止類似所打印的字符串中出現單或雙引號,當然也可以用轉義字符來解決 \" \'
(2)三單與三雙 與單的區別
三引號可以允許字符串裏面出現換行符,打印文章
2、三種字符串
    長字符串 用三引號聲明
    Unicode字符串 使用u作爲前綴,可以說是ASCII碼的擴展版
    原始字符串 用r做前綴,不會對反斜線特殊對待,就是說原始字符串不進行轉義
3、格式化字符串
類似於C語言中的格式控制符,
實例:
pi = 3.14159
>>> format = "pi is %.3f" %  pi

name = "zhanchang xiaobao"
>>> format = "my name is %s" % name

格式轉換符(與C語言同)

4、擴展 (模板字符串)
string 模塊
實例 :subtitute 會將傳遞進來的foo替換$foo
>>> from string import Template
>>> s = Template('$x ,glorious $x!')
>>> s.subtitute(x='slurm')
如果被替換部分爲單詞的一部分,那麼參數名就必須用{}括起來
用$$插入$符號
方法 safe_subtitute 不會因缺少值或者不正確使用$而出錯

5、字符串方法
(1)、find 返回子串最左端的索引,找不到返回-1
(2)、index類似於find,但不能查找不存在的子串否則,會報錯
(3)、count返回出現次數
(4)、join 添加分隔符,split的逆方法
    實例:(被連接的元素必須是字符串)
        sep = '+'
        s = ['1','2','3','4']
        >>> s.join(sep)
        1+2+3+4
(5)、split 分割字符串成一個列表
        實例:
        sep = '+'
        s = '1+2+3+4'
        >>> s.split(sep)
        ['1','2','3','4']
(6)、lower 全部小寫(標準化)
(7)、title 所有單詞的首字母都大寫,但是有時候會出現不自然的情況
    capwords(來源於string模塊)
        實例:
        import string
        >>> string.capwords("that's ok")
        That's Ok
(8)、replace 替換子串(但注意字符串是不可變現象)
(9)、strip 返回去除兩側(不包含內部)的字符串,默認刪除空格
        實例:
        s = "***!!!liyilin***!!!"
        >>>s.strip("*!")
        liyilin
(10)、translate 只替換單個字符,可同時進行多個替換,有些時候
效率高於replace(更換某些銀平臺而異的字符)
    轉換之前需先完成一張轉換表,直接調用string模塊裏的maketrans函數
(10)2、maketrans方法接受兩個參數:等長字符串,表示第一個字符串裏的每個字符都用
第二個字符串裏的對應位置字符替換
        實例:
        from string import maketrans
        table = maketrans("cs","kz")
        s = "this is an incredible text"
        >>>s.translate(table)
        thiz iz an inkredible text
translate的第二個參數是可選的,代表指定要刪除的字符
(11)、成員資格 in
(12)、支持切片



應用:可以利用字符串的知識,寫一個超簡單的入門級爬蟲,抓取圖片,可以使用find函數,也可以直接遍歷找開始位置和結束位置


抓取青島科技大學主頁圖片爬蟲代碼


#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib  //網絡包


s = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="zh-cn"><head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <meta http-equiv="Content-Language" content="zh-CN" />    <title>青島科技大學</title>    <meta name="Keywords" content="青島科技大學" />    <meta name="Description" content="青島科技大學" />    <meta name="Author" content="博網www.urlbase.cn,青島網站專家,獨家設計、開發" />    <link href="/App_Themes/commonStyle/basic.css" rel="stylesheet" type="text/css" />    <link href="/App_Themes/commonStyle/index.css" rel="stylesheet" type="text/css" />    <script src="/App_JS/jquery.js" type="text/javascript"></script>    <script src="/App_JS/jquery.cycle.all.min.js" type="text/javascript"></script>    <script src="/App_JS/js_top.js" type="text/javascript"></script>    <script src="/App_JS/js_index.js" type="text/javascript"></script></head><body>    <div id="div_top">    <div id="div_logo">    </div>    <div id="div_360">        <a href="http://www.qust.edu.cn/360/" target="_blank"><img src="http://www.qust.edu.cn/images/pic360.gif" height="77" width="138" alt="全景校園Logo" /></a>    </div>    <div id="div_schoolmotto">    </div>    <div id="div_mobile"><img src="/images/mobile.gif" width="10" height="16" alt="" />手機訪問-> <a href="http://m.qust.edu.cn" target="_blank">m.qust.edu.cn</a>    </div>    <dl style="margin-left: 60px;"><dt>新聞資訊</dt><dd><a href="http://xinwen.qust.edu.cn/" target="_blank">新聞網</a><a href="http://www.qust.edu.cn/AppAdmin/detail.aspx?articleId=22891" target="_blank">微博微信</a><a href="http://news.qust.edu.cn/" target="_blank">青島科技大學報</a><a href="http://gb.qust.edu.cn/" target="_blank">廣播臺</a><a href="http://tv.qust.edu.cn/" target="_blank">電視臺</a></dd><dt>校情總覽</dt><dd><a href="/info.aspx?categoryId=37" target="_blank">學校簡介</a><a href="/info.aspx?categoryId=38" target="_blank">歷史沿革</a><a href="/info.aspx?categoryId=39" target="_blank">現任領導</a><a href="/info.aspx?categoryId=41" target="_blank">遠景規劃</a><a href="/info.aspx?categoryId=40" target="_blank">校園美景</a><a href="http://www.qust.edu.cn/360/" target="_blank">全景校園</a></dd><dt><a href="/org.aspx" target="_blank">機構設置</a></dt><dd><a href="/org.aspx" target="_blank">黨羣機構</a><a href="/org.aspx" target="_blank">行政機構</a><a href="/org.aspx" target="_blank">直屬單位</a><a href="/org.aspx" target="_blank">直屬研究所</a></dd><dt><a href="/area.aspx" target="_blank">院部設置</a></dt><dd><a href="/area.aspx" target="_blank">嶗山校區</a><a href="/area.aspx" target="_blank">四方校區</a><a href="http://gmxq.qust.edu.cn/" target="_blank">高密校區</a></dd><dt class="noson"><a href="teach.aspx" target="_blank">教育教學</a></dt><dd><a href="http://jw.qust.edu.cn/" target="_blank">本專科教育</a><a href="http://grad.qust.edu.cn/" target="_blank">研究生教育</a><a href="http://ieco.qust.edu.cn/" target="_blank">留學生教育</a><a href="http://cj.qust.edu.cn/" target="_blank">成教職教</a><a href="http://sbc.qust.edu.cn/" target="_blank">條件裝備</a><a href="http://211.87.159.40:8017/" target="_blank">網絡教學平臺</a><a href="http://wlkc.qust.edu.cn/wlkcindex" target="_blank">網絡課程</a><a href="http://jpkc.qust.edu.cn/" target="_blank">精品課程</a><a href="http://211.87.159.40:8018/" target="_blank">名師講堂</a><a href="http://211.87.159.40:8019/" target="_blank">現場教學錄像網</a><a href="http://211.87.159.40:8020/" target="_blank">國內外開放課程</a><a href="http://oes.qust.edu.cn/" target="_blank">英語學習</a><a href="http://ls.qust.edu.cn/" target="_blank">史鑑在線</a><a href="http://mg.qust.edu.cn/" target="_blank">毛澤東思想網站</a><a href="http://jpkc.qust.edu.cn/ppzy/default.htm" target="_blank">品牌與特色專業</a><a href="http://opensteam.qust.edu.cn/" target="_blank">教育管理平臺</a></dd><dt>科學研究</dt><dd><a href="http://ece.qust.edu.cn/" target="_blank">國家重點實驗室培育基地</a><a href="http://rubber.qust.edu.cn/" target="_blank">橡塑材料與工程教育部重點實驗室</a><a href="http://satm.qust.edu.cn/" target="_blank">腫瘤標誌物傳感分析教育部重點實驗室</a><a href="http://www.nercrat.com/userview/index.jsp" target="_blank">國家橡膠與輪胎工程技術研究中心</a><a href="http://gtr.qust.edu.cn" target="_blank">協同創新中心</a><a href="http://xbzr.qust.edu.cn/" target="_blank">學報(自然版)</a><a href="http://qdhs.chinajournal.net.cn/WKE/WebPublication/index.aspx?mid=QDHS" target="_blank">學報(社科版)</a></dd><dt>學生工作</dt><dd><a href="http://grad.qust.edu.cn/" target="_blank">研究生工作</a><a href="http://student.qust.edu.cn/index.asp" target="_blank">教育管理</a><a href="http://xszz.qust.edu.cn/index.asp" target="_blank">學生資助</a><a href="http://xlzx.qust.edu.cn/" target="_blank">心理中心</a><a href="http://student.qust.edu.cn/guofang/index.asp" target="_blank">國防教育</a><a href="http://tw.qust.edu.cn/qgzx/" target="_blank">勤工助學</a><a href="http://tw.qust.edu.cn/hytx/" target="_blank">弘毅團校</a><a href="http://www.tiaozhanbei.net/d332/" target="_blank">創新創業</a></dd><dt>人才招聘</dt><dd><a href="http://rsc.qust.edu.cn/new/News_View.asp?NewsID=971" target="_blank">師資隊伍</a><a href="/list.aspx?categoryId=1667" target="_blank">人才招聘</a></dd><dt>招生就業</dt><dd><a href="http://grad.qust.edu.cn" target="_blank">研究生招生</a><a href="http://zs.qust.edu.cn/" target="_blank">本專科招生</a><a href="http://cj.qust.edu.cn/" target="_blank">成人教育招生</a><a href="http://ieco.qust.edu.cn/liuxuekeda/" target="_blank">留學生招生</a><a href="http://job.qust.edu.cn/" target="_blank">就業指導</a></dd><dt>合作交流</dt><dd><a href="http://ieco.qust.edu.cn/" target="_blank">國際交流</a><a href="http://ieco.qust.edu.cn/ENGLISH/" target="_blank">International Students</a><a href="http://ieco.qust.edu.cn/Korea/" target="_blank">???</a></dd><dt>校園文化</dt><dd><a href="http://www.qust.edu.cn/AppAdmin/detail.aspx?articleId=17146" target="_blank">UIS</a><a href="http://su.qust.edu.cn/" target="_blank">學生會</a><a href="http://st.qust.edu.cn/" target="_blank">學生社團</a><a href="http://www2.qust.edu.cn/xueshengshequ.html" target="_blank">學生社區</a><a href="http://qdkdxzzj.qust.edu.cn/" target="_blank">學子之家</a></dd><dt class="noson"><a href="http://en.qust.edu.cn/" target="_blank">English</a></dt><dd></dd>    </dl><br class="clearfloat" /><img src="/images/topmenu_hover.jpg" width="10" height="8" alt="hover" id="img_hover" /><div id="menu_son"></div></div>    <div class="main_div">        <div id="main_left">        </div>        <div id="main_middle">            <div class="float_left">
    <div id="div_slide">
<ul><li><a href="/detail.aspx?articleId=25854" target="_blank"><img src="http://www.qust.edu.cn/images/slide/20160523043558.jpg" width="426" height="285" alt="" /><br />  青科大舉辦2016年“相約科大”校園開放日活動</a></li><li><a href="/detail.aspx?articleId=25851" target="_blank"><img src="http://www.qust.edu.cn/images/slide/20160523043537.jpg" width="426" height="285" alt="" /><br />  高等學校化學化工學科國家級實驗教學示範中心建設暨雙</a></li><li><a href="/detail.aspx?articleId=25796" target="_blank"><img src="http://www.qust.edu.cn/images/slide/20160518051125.jpg" width="426" height="285" alt="" /><br />  青島市人大常委會主任王文華來校調研僑務工作</a></li><li><a href="/detail.aspx?articleId=25756" target="_blank"><img src="http://www.qust.edu.cn/images/slide/20160513052344.jpg" width="426" height="285" alt="" /><br />  黨委書記劉興雲考察調研學校第一書記工作</a></li><li><a href="/detail.aspx?articleId=25666" target="_blank"><img src="http://www.qust.edu.cn/images/slide/20160509035613.jpg" width="426" height="285" alt="" /><br />  青科大2016年學生田徑運動會舉行</a></li></ul>        <div id="controls">
            <span id="pagerNav"></span>
        </div>
    </div>
    <br class="clearfloat" />
<dl><dt><img src="/images/guide.jpg" width="76" height="16" alt="快速通道" /></dt><dd><a href="http://oa.qust.edu.cn" target="_blank">網上辦公</a></dd><dd><a href="http://oa.qust.edu.cn/huiyi/" target="_blank">會議安排</a></dd><dd><a href="http://mail.qust.edu.cn" target="_blank">在線郵件</a></dd><dd><a href="http://www.qust.edu.cn/xiaonei/tel.htm" target="_blank">常用電話</a></dd><dd><a href="/sitemap.aspx" target="_blank">網站地圖</a></dd><dd><a href="http://library.qust.edu.cn/" target="_blank">圖 書 館</a></dd><dd><a href="http://jj.qust.edu.cn/category.asp?flag=29" target="_blank">黨務公開</a></dd><dd><a href="http://xxgk.qust.edu.cn/" target="_blank">信息公開</a></dd><dd><a href="mailto:[email protected]" target="_blank">校長信箱</a></dd><dd><a href="http://211.87.155.19/" target="_blank">教務管理</a></dd><dd><a href="http://dag.qust.edu.cn/" target="_blank">學歷認證</a></dd><dd><a href="http://xyh.qust.edu.cn/" target="_blank">校友總會</a></dd><dd><a href="http://www.alumninet.net/" target="_blank">校 友 網</a></dd><dd><a href="http://edf.qust.edu.cn/" target="_blank">基 金 會</a></dd><dd><a href="http://bbs.qust.edu.cn" target="_blank">傳薪論壇</a></dd><dd><a href="http://nic.qust.edu.cn/" target="_blank">網絡服務</a></dd><dd><a href="http://jw.qust.edu.cn/cxfw/kdxlcx.htm" target="_blank">科大校歷</a></dd><dd><a href="http://www.qust.edu.cn/navi.aspx" target="_blank">大學導航</a></dd><dd><a href="http://hqc.qust.edu.cn/" target="_blank">後勤服務</a></dd><dd><a href="http://www.qust.edu.cn/AppAdmin/detail.aspx?articleId=22891" target="_blank">微博微信</a></dd><dt class="clearfloat"></dt></dl></div>
<div class="float_right">
<dl><dt><a href="/list.aspx?categoryId=1663" target="_blank" class="tab_ban_hover" id="1663">科大要聞</a><a href="/list.aspx?categoryId=1720" target="_blank" class="tab_ban_unhover" id="1720">校園傳真</a><a href="/list.aspx?categoryId=1664" target="_blank" class="tab_ban_unhover" id="1664">媒體科大</a><a href="/list.aspx?categoryId=1663" target="_blank" class="link_more">>>更多</a><img src="/images/tab_arrow.jpg" width="8" height="7" alt="" /><br class="clearfloat" /></dt><dd><ul id="ul_1663" style='display:block;'><li><a href="/detail.aspx?articleId=25854" style="color:#1462AD" title="青科大舉辦2016年“相約科大”校園開放日活動" target="_blank">青科大舉辦2016年“相約科大”校園開放日活動</a><em>05月21日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25853" style="color:#1462AD" title="“明德書屋”走進第一書記幫包村" target="_blank">“明德書屋”走進第一書記幫包村</a><em>05月22日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25852" style="color:#1462AD" title="青科大黨外代表人士赴蒙陰莒縣考察調研" target="_blank">青科大黨外代表人士赴蒙陰莒縣考察調研</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25851" style="color:#1462AD" title="高等學校化學化工學科國家級實驗教學示範中心建設暨雙創建設主題課堂在青科大舉辦" target="_blank">高等學校化學化工學科國家級實驗教學示範中心建設暨雙創建設</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25849" style="color:#1462AD" title="青科大獲2015年度山東高校優秀新聞獎" target="_blank">青科大獲2015年度山東高校優秀新聞獎</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25813" title="省科技廳黨組成員、青島國家海洋科學研究中心主任李乃勝一行來青科大調研" target="_blank">省科技廳黨組成員、青島國家海洋科學研究中心主任李乃勝一行</a><em>05月19日</em><br class="clearfloat" /></li></ul><ul id="ul_1720" style='display:none;'><li><a href="/detail.aspx?articleId=25844" style="color:#1462AD" title="我校學生聞益智獲評山東高校十大優秀學生提名獎" target="_blank">我校學生聞益智獲評山東高校十大優秀學生提名獎</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25839" title="寧夏團區委和校團委爲青科大第十七屆研支團成員舉辦特殊“畢業典禮”" target="_blank">寧夏團區委和校團委爲青科大第十七屆研支團成員舉辦特殊“畢</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25838" title="圖書館“兩學一做”專題書架揭牌" target="_blank">圖書館“兩學一做”專題書架揭牌</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25837" title="中德科技學院成爲互聯網工業服務商(國際)聯盟成員" target="_blank">中德科技學院成爲互聯網工業服務商(國際)聯盟成員</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25835" title="經管學院舉行首期班級沙龍活動" target="_blank">經管學院舉行首期班級沙龍活動</a><em>05月19日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25829" title="副校長張元利出席四方校區北門落成儀式" target="_blank">副校長張元利出席四方校區北門落成儀式</a><em>05月20日</em><br class="clearfloat" /></li></ul><ul id="ul_1664" style='display:none;'><li><a href="/detail.aspx?articleId=25815" style="color:#1462AD" title="【中國教育報】青島科技大學:“校友招校友”招聘會受青睞" target="_blank">【中國教育報】青島科技大學:“校友招校友”招聘會受青睞</a><em>05月18日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25768" style="color:#1462AD" title="【中國科學報】中國“橡膠黃埔”的“老兵”" target="_blank">【中國科學報】中國“橡膠黃埔”的“老兵”</a><em>05月13日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25855" style="color:#1462AD" title="【山東商報】高考交流羣“走進大學”第四站落腳青島科技大學" target="_blank">【山東商報】高考交流羣“走進大學”第四站落腳青島科技大學</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25841" title="【青島早報】頭版:青科大3名大學生創立“極客工場” 用無人機拍出創意畢業照的同時實現了創業夢" target="_blank">【青島早報】頭版:青科大3名大學生創立“極客工場” 用無人</a><em>05月21日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25817" title="【山東省教育廳】青科大舉辦“創客嘉年華”推動大學生科技創新" target="_blank">【山東省教育廳】青科大舉辦“創客嘉年華”推動大學生科技創</a><em>05月19日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25816" title="【中青網】【大衆網】青科大當選中國製造業知識服務聯盟理事單位" target="_blank">【中青網】【大衆網】青科大當選中國製造業知識服務聯盟理事</a><em>05月17日</em><br class="clearfloat" /></li></ul></dd></dl><div style="height:30px;"></div>
<dl><dt><a href="/list.aspx?categoryId=1666" target="_blank" class="tab_ban_hover" id="1666">校園公告</a><a href="/list.aspx?categoryId=1745" target="_blank" class="tab_ban_unhover" id="1745">校內通知</a><a href="/list.aspx?categoryId=1665" target="_blank" class="tab_ban_unhover" id="1665">學術動態</a><a href="/list.aspx?categoryId=1666" target="_blank" class="link_more">>>更多</a><img src="/images/tab_arrow.jpg" width="8" height="7" alt="" /><br class="clearfloat" /></dt><dd><ul id="ul_1666" style='display:block;'><li><a href="/detail.aspx?articleId=25814" style="color:#1462AD" title="關於開展網站羣系統推廣工作的通知" target="_blank">關於開展網站羣系統推廣工作的通知</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25845" style="color:#1462AD" title="2016年高雅藝術進校園——中央歌劇院走進青島科技大學演出公告" target="_blank">2016年高雅藝術進校園——中央歌劇院走進青島科技大學演出公</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25828" title="青島科技大學幼兒園2016年暑期大二教室室內修繕與改造工程" target="_blank">青島科技大學幼兒園2016年暑期大二教室室內修繕與改造工程</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25827" title="青島科技大學幼兒園2016年暑期塑鋼窗更換工程" target="_blank">青島科技大學幼兒園2016年暑期塑鋼窗更換工程</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25826" title="青島科技大學工程設計和仿真教學電腦及桌椅公開採購招標公告" target="_blank">青島科技大學工程設計和仿真教學電腦及桌椅公開採購招標公告</a><em>05月20日</em><br class="clearfloat" /></li></ul><ul id="ul_1745" style='display:none;'><li><a href="/detail.aspx?articleId=25781" style="color:#1462AD" title="關於開展專項督查工作的通知" target="_blank">關於開展專項督查工作的通知</a><em>05月17日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25846" style="color:#1462AD" title="關於組織申報青島市教育科學“十三五”規劃課題的通知" target="_blank">關於組織申報青島市教育科學“十三五”規劃課題的通知</a><em>05月23日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25842" style="color:#1462AD" title="關於舉辦2016年“靈狐”杯青島科技大學“互聯網+”大學生創新創業大賽暨山東省“互聯網+”大學生創新創業大賽選拔賽的通知" target="_blank">關於舉辦2016年“靈狐”杯青島科技大學“互聯網+”大學生創</a><em>05月22日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25821" title="關於公佈2016年“高信杯”青島科技大學數學建模競賽獲獎名單的通知" target="_blank">關於公佈2016年“高信杯”青島科技大學數學建模競賽獲獎名單</a><em>05月19日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25790" title="青島科技大學四方校區財務處到賬確認通知" target="_blank">青島科技大學四方校區財務處到賬確認通知</a><em>05月17日</em><br class="clearfloat" /></li></ul><ul id="ul_1665" style='display:none;'><li><a href="/detail.aspx?articleId=25840" title="藝術學院:張曉曉獨唱音樂會" target="_blank">藝術學院:張曉曉獨唱音樂會</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25832" title="信息學院學術報告: 信息技術現在和未來" target="_blank">信息學院學術報告: 信息技術現在和未來</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25831" title="馬克思主義學院研究生論壇:新型智庫對中國特色社會主義先進文化建設的作用" target="_blank">馬克思主義學院研究生論壇:新型智庫對中國特色社會主義先進</a><em>05月20日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25820" title="藝術學院藝講堂:意大利美聲唱法的教學與演唱" target="_blank">藝術學院藝講堂:意大利美聲唱法的教學與演唱</a><em>05月19日</em><br class="clearfloat" /></li><li><a href="/detail.aspx?articleId=25811" title="圖論在量子通信中的一個應用-不可擴大的量子乘積態組(UPB)" target="_blank">圖論在量子通信中的一個應用-不可擴大的量子乘積態組(UPB)</a><em>05月19日</em><br class="clearfloat" /></li></ul></dd></dl></div>
<br class="clearfloat" />
<div id="foot_ad">
<div class='ddl_link'><select><option disabled="disabled" selected="selected">友情鏈接</option><option value="http://www.moe.edu.cn/">教育部</option><option value="http://www.most.gov.cn/">科技部</option><option value="http://www.nsfc.gov.cn/">國家自然科學基金委</option><option value="http://www.cutech.edu.cn/cn/index.htm">教育部科技發展中心</option><option value="http://www.sipo.gov.cn/sipo2008/">國家知識產權局</option><option value="http://conf.cnki.net/">中國學術會議</option><option value="http://www.sdedu.gov.cn/">山東省教育廳</option><option value="http://www.sdstc.gov.cn/HomePage">山東省科技廳</option><option value="http://www.sdpatent.gov.cn/">山東省知識產權局</option><option value="http://www.qdstc.gov.cn/">青島市科技局</option></select></div><div class='ddl_link'><select><option disabled="disabled" selected="selected">友好學校</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/54.html">德國</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/56.html">美國</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/57.html">法國</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/59.html">英國</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/58.html">日本</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/53.html">韓國</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/52.html">俄羅斯</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/60.html">加拿大</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/62.html">意大利</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/63.html">烏克蘭</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/55.html">澳大利亞</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/61.html">愛沙尼亞</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/64.html">馬來西亞</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/65.html">中國香港</option><option value="http://ieco.qust.edu.cn/jinxiu/2010-09-11/66.html">中國臺灣</option></select></div><div class='ddl_link'><select><option disabled="disabled" selected="selected">專題網頁</option><option value="http://xinwen.qust.edu.cn/sub.aspx?subjectId=1854">青科大培育和踐行核心價值觀專題網站</option><option value="http://theory.people.com.cn/GB/40557/120709/index.html">人民網:培育和踐行社會主義核心價值觀專題</option><option value="http://xinwen.qust.edu.cn/sub.aspx?subjectId=1798">“增強服務意識,提高服務質量”主題教育活動</option><option value="http://xinwen.qust.edu.cn/sub.aspx?subjectId=1780">深入開展學習雷鋒活動</option><option value="http://jyhf.qust.edu.cn/new/ ">教育行風民主評議專題網站</option><option value="http://cxzy.qust.edu.cn/">創先爭優</option><option value="http://pgb.qust.edu.cn/">教學評估</option><option value="http://xq.qust.edu.cn/">校慶專題</option><option value="http://kdln.qust.edu.cn/">科大老年網</option><option value="http://kdsz.qust.edu.cn/">思政課專題</option><option value="http://jj.qust.edu.cn/">廉政網</option></select></div><div><form action="query.aspx" method="post" target="_blank"><input type="text" name="txtquery" id="txtquery" class="text_style" /><input type="submit" value="" class="btn_style" id='btnQuery' /></form></div><br class="clearfloat" /><a href="http://xinwen.qust.edu.cn/detail.aspx?articleId=25045" target="_blank"><img src="/images/ad/20160303094715.jpg" width="450" alt="" height="53" /></a><a href="http://www.qust.edu.cn/detail.aspx?articleId=24788" target="_blank"><img src="/images/ad/20160415120942.jpg" width="160" alt="" height="53" /></a><a href="http://xinwen.qust.edu.cn/sub.aspx?subjectId=1895" target="_blank"><img src="/images/ad/20160428165635.jpg" width="160" alt="" height="53" /></a><a href="http://gmxq.qust.edu.cn/" target="_blank"><img src="/images/ad/20111227100023.jpg" width="160" alt="" height="53" /></a><br class="clearfloat" /></div>
        </div>        <div id="main_right">        </div>        <br class="clearfloat" />    </div>    <div id="div_foot">
<div class="float_left"><a href="http://www.qdbeian.com/RecordDetail.aspx?WebID=4954" target="_blank"><img src="/images/cert.gif" width="30" height="27" alt="" /></a></div>    <div class="float_left">校址:青島市松嶺路99號(嶗山校區) 郵編:266061 青島市鄭州路53號(四方校區) 郵編:266042  山東省高密市杏壇西街1號(高密校區) 郵編:261500<br />
    版權所有 青島科技大學 Email:[email protected]</div>
<br class="clearfloat" /></div>
</body></html>"""


temp = 'http://www.qust.edu.cn/images/slide/20160523043558.jpg'

length =  len(temp)

head = 'img src="http:'
tail = ".jpg"
posx = -len(head)
posy = -len(tail)

i = 0
while i < s.count(head):
    posx = s.find(head,posx+len(head))
    posy = s.find(tail,posx+len(tail))
    if posy + len(tail) - posx == 63 :
        url = s[posx+9:posy+len(tail)]
        urllib.urlretrieve(url , str(i) + '.jpg')
    i = i+1

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章