• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 195,  comments - 30,  trackbacks - 0
            注意,我們只是簡單的提取// 以及/* */之間的內(nèi)容。
            如果 程序中出現(xiàn)了“/*”,會(huì)有bug

            #!/usr/bin/env python

            import sys
            import re

            def comment_finder(text):
                pattern = re.compile( r'//.*?$|/\*.*?\*/', re.DOTALL | re.MULTILINE)
                result = pattern.findall(text)
                return result

            def print_command(filename):

                codefile = open(filename,'r')
                commentfile = open(filename+".txt",'w')
                lines=codefile.read()
                codefile.close()
                #the list of comments
                list_of_comments = comment_finder(lines)
                for comment in list_of_comments:
                    #print comment[0:2]
                    if comment[0:2] == "//":
                            comment_to_write = comment[2:]
                    else:
                        comment_to_write = comment[2:-2]
                    if len(comment_to_write)!=0:
                        commentfile.write(comment_to_write)
                    commentfile.write('\n')
                commentfile.close()

            if __name__ == "__main__":
                for filename in sys.argv[1:]:
                    print_command(filename)
            使用:

            在linux下面 轉(zhuǎn)到當(dāng)前目錄 ./get_comment.py *
            或者 指定文件類型
            ./get_comment.py *.c
            posted on 2012-12-03 08:35 luis 閱讀(1393) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Python
            <2012年12月>
            2526272829301
            2345678
            9101112131415
            16171819202122
            23242526272829
            303112345

            常用鏈接

            留言簿(3)

            隨筆分類

            隨筆檔案

            文章分類

            文章檔案

            友情鏈接

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            精品无码久久久久久午夜| 久久亚洲国产成人精品性色| 69久久夜色精品国产69| 亚洲女久久久噜噜噜熟女| 2021最新久久久视精品爱| 波多野结衣久久一区二区| 久久久久亚洲AV无码观看 | 久久精品国产亚洲av麻豆小说| yy6080久久| 久久精品中文字幕无码绿巨人| 狠狠色丁香久久综合五月| 国产高潮国产高潮久久久91| 久久久久久A亚洲欧洲AV冫| 久久99精品久久久久久| 91久久精品无码一区二区毛片| 久久青青草原精品国产不卡| 国产偷久久久精品专区| 久久99精品国产| 久久91精品国产91| 久久九九亚洲精品| 久久久一本精品99久久精品88| 狠狠色丁香久久婷婷综| 久久精品中文字幕大胸| 青青草国产精品久久| 亚洲欧美日韩精品久久亚洲区| 97久久国产亚洲精品超碰热| 亚洲欧美另类日本久久国产真实乱对白 | 久久久久99精品成人片试看| 大蕉久久伊人中文字幕| 久久综合狠狠综合久久| 久久天天婷婷五月俺也去| 国产成人久久精品麻豆一区| 久久天天躁狠狠躁夜夜avapp| 久久久久这里只有精品| 久久精品国产亚洲麻豆| 香蕉久久av一区二区三区| 一本一本久久a久久精品综合麻豆| 青青草国产精品久久久久| 999久久久免费精品国产| 亚洲欧美日韩中文久久| 一本色道久久88精品综合 |