Contenido del archivo de Python para ser leído por otro archivo de Python e imprimir el contenido

python file contents to be read by another python file and print the content

taking 2 python files

one.py

print (content of two.py)

dos.py

if any(data):
    print data
    validate()
    random()

resultado:

if any(data):
    print data
    print data
    validate()
    random()

es eso posible

preguntado el 02 de febrero de 12 a las 10:02

Is this somewhat related to tu pregunta anterior? If it is please make one good clear question, not two confused. -

yes am very much confused how to ask that question..i am newbie to python...sorry for troubles -

are you trying to write a quine? -

not quine sort..what i am exactly trying to is create a test case automation...where i had some issue in our earlier model of importing test case data from excel..on discussions now we thought if the test case can be written in test scripts form where the main thread will read the test script thread and interpret the defined functions ...also the test scripts can do actions like direct validations... -

2 Respuestas

If you want to execute another python program from your python program or from python prompt then you can just import os and execute command using os.system como a continuación

One.py may be as below

import os
os.system('./two.py')
#process further

Respondido 02 Feb 12, 15:02

Seguro que puede:

with open("two.py") as two:
    for line in two:
      print line,

Respondido 02 Feb 12, 14:02

is there any way to excute that line - Ragav

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.