8
Apr

python ile basit bir kod wrapper örneği

   Posted by: İsmail ÇAKIR   in python

import sys

pre = ‘out.println("‘ # satirbasi sql.append(" gibi
pst = ‘")‘            # satirsonu ") gibi
addslash = 1          # tirnaklara backslash

if len(sys.argv) == 1:
    print "kullanim: \n \t\t  wrapper.py giris.txt \n  \t\t  > cikis.txt gerekiyorsa"
    sys.exit(1)

f = open(sys.argv[1] ,’r‘)

for r in f:
    if (addslash == 1):
        r = r.replace(‘"‘,’\\"‘)
    r = r.rstrip()
    line =  "%s%s%s" % (pre , r, pst)
    print line

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Tags: ,

Tags: ,

This entry was posted on Thursday, April 8th, 2010 at 14:36 and is filed under python. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Cevap veya Yorum Yaz

İsminiz (*)
e-Mail (Burada yayınlanmayacak endişelenmeyin) (*)
Web Siteniz
Yorumunuz
Powered by sweet Captcha

Switch to our mobile site

Email
Print
WP Socializer Aakash Web