Jump to content
Guest

Ajutor programare python

Recommended Posts

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?

Link to comment
Share on other sites

[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())

Link to comment
Share on other sites

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...