zoukankan      html  css  js  c++  java
  • py_assignment1

    #################################################################
    #  my program's method to achieve the mission is by through     #
    #  creating a new file --"temp.py" to record the modify results #
    #  and then to delete the previous target file--"sys.py"        #
    #  after that we rename the "temp.py" as "sys.py"               #
    #################################################################
    import os
    file = open("sfs.py",'r')   #open the target file which is "sfs.py"
    f = open("temp.py",'w')     #create a new file for recording the modify results
    cnt=0;                      #count the lines
    for line in file.readlines():
        cnt=cnt+1;
        if(cnt!=52) :
            f.write(line)
        if cnt==52 :
            line=line.strip('
    ')            #delete the '
    ' in order to not get to the new line
            line=line.__add__('; print( "Virus" )')#add the target string
            line=line.__add__('
    ')                #add '
    '
            f.write(line)
    file.close()                  #close the target file
    f.close()                     #close the modify file
    os.remove("sfs.py")           #delete the target file
    os.rename("temp.py", "sfs.py")#rename the modify file's name as previous target file
    View Code
  • 相关阅读:
    Oracle FGA审计记录的清理步骤
    UVa11488-Hyper Prefix Sets(trie树)
    配置Log4j(非常具体)
    poj1190生日蛋糕
    zju1610Count the Colors
    【例9.3】求最长不下降序列
    P1364 医院设置
    P1629 邮递员送信
    P1476 休息中的小呆
    P1330 封锁阳光大学
  • 原文地址:https://www.cnblogs.com/Anonytt/p/14041392.html
Copyright © 2011-2022 走看看