Jump to content
Guest

Ajutor programare python

Recommended Posts

Posted

import sys

start = sys.argv[1]

end = sys.argv[2]

f = open('ms/1.txt', 'r')

l = [l for l in f.readlines()[start:end] if l.strip()]

f.close()

print l

nu imi recunoaste variabilele, daca inlocuiesc variabilele cu cifre merge.... vreo idee?

Posted

[int(start):int(end)]

start si end sunt de tip str() deoarece lista de argumente (sys.argv) iti ia parametrii ca siruri nu ti le interpreteaza automat ca input() (pentru care lucru e valabil in 2.x din cauza existentei si lui raw_input())

Posted

asta e , merci frumos. eu am rezolvat temporar cu

f=os.popen("head -"+limit+" ./ms/1.txt | tail -50")

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...