Wednesday 15 August 2012

variables - pass stryng between two python scripts -


I have to give a string value between two dragon scripts.

This is not a logic, but it is a string in which sentence (spaces, commas, and so on).

Example:

A string variable in "py" Hello world, how are you today? "

And let me do it 2.py

How do I get this result?

this is not a logic but it is a string in which the sentence (spaces, commas, and so on) Along the way).

Why is not such a reason?

I do not know how you were planning to run another script, but a very different way of doing this allows you to pass the string as empty space, with commas and logic is.

If you are doing things smart, then it works automatically:

  subprocess.check_call ([sys.exrectable, path_to_script2, arg]) < / Code>  

If you are doing something like os.system you have to manually cite the logic to engrave it through intent.? | But the easiest answer is "Do not use os.system , so I will not show how to do this unless you specifically ask for it.

In any way , When script2 runs, its sys.argv [1] will be arg , with spaces and commas and so on. P>


If the string is too large, you can participate in problems with maximum RGV length and worse than that, they are different platforms There may be different problems.

In addition, if you are using Unicode, especially in Python 2.x, there may be some complications in it.

However, short-ash ASCII strings like "Hello World, how are you today? ", this is all trivial.

No comments:

Post a Comment