码迷,mamicode.com
首页 > 编程语言 > 详细

旧文-初学python-2007-10-07 21:19

时间:2017-06-28 21:56:47      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:翻译   adl   链接   简单   汇编   ecif   推荐   this   pytho   

 

从昨天晚上开始,学习了一下python。看的这本翻译的教程,写得很好,浅显易懂,推荐给入门用户。
wiki上的链接也很有用。
另外,当作练手写了一个去除51汇编程序的注释的小程序。非常简单。

 

#!/usr/bin/python
# Filename : anticom.py
""" delete the comment of a given assembly file"""

import sys

if len(sys.argv) < 2:
    print ‘No file name specified.‘
    sys.exit()

filename = sys.argv[1]
f = file(filename)
f_out = file( ‘new‘ + filename,‘w‘)

while True:
    line = f.readline()
    if len(line) == 0:
        break

    a=line.find(‘;‘) #if this line has no ‘;‘, a=-1, it‘s just OK
    newline=line[:a] + ‘; ‘
    f_out.write(newline)

f.close
f_out.close

  

旧文-初学python-2007-10-07 21:19

标签:翻译   adl   链接   简单   汇编   ecif   推荐   this   pytho   

原文地址:http://www.cnblogs.com/yushiyou/p/7091434.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!