Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to store the value from variable into list & run a statement then put in variable
#1
Hi, I have 2 question regarding this code, 1st I want to put all the values into list from the variable?

Example, Im grepping multiple ip from a file.
f = os.popen('grep '+ ip[i] + ' *')
now = f.read()
print ("output: ", now)
2nd from 1 there will be 2 possible output 1 is no match and 2 will be the matched output from grep.

If theres no match then I should put a word none in the list while if there a match I need to put exist?

I think I can do it using if else but totally blind in where to start haha. Still searching for sample command.

Thanks
Quote
#2
Your 1st question:
list_lines = now.splitlines()
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  cacul in variable MathisDELAGE 2 80 Nov-15-2019, 10:00 PM
Last Post: micseydel
  using module variable jacklee26 4 105 Nov-13-2019, 01:36 AM
Last Post: jacklee26
  Variable Issue slackerman73 2 79 Nov-09-2019, 04:34 PM
Last Post: slackerman73
  Importing a .py file with a value of a variable Sk4rd 2 191 Nov-09-2019, 08:29 AM
Last Post: buran
  How I can use multiprocessing with upickled module variable? AlekseyPython 3 194 Oct-31-2019, 06:09 AM
Last Post: AlekseyPython
  How to print variable name? mayadob 11 312 Oct-21-2019, 01:34 AM
Last Post: ichabod801
  local variable troubles yokaso 4 159 Oct-20-2019, 05:25 PM
Last Post: ichabod801
  Variable comments on Visual Studio Code sal 2 148 Oct-19-2019, 02:13 PM
Last Post: sal
  Can I use iteration to create variable names? Mark17 8 260 Oct-17-2019, 06:05 AM
Last Post: perfringo
  random variable function? Novice_fanatic 4 154 Oct-08-2019, 01:22 PM
Last Post: jefsummers

Forum Jump:


Users browsing this thread: 1 Guest(s)