Home > other >  If __name__=="__main__ ': cannot use print
If __name__=="__main__ ': cannot use print

Time:09-23

Themselves to write some examples to enhance understanding of multiprocess, but ran into another problem,
As follows, I intend to look at the process with wait loop method how to perform, but found that no matter how to print out, my child can normal print, is this why? I am using vscode,

If __name__=="__main__ ':
P=the Process (target=f, args=(' Bob '))
M=0
While True:
M +=1
Time. Sleep (1)
Print (' m is % d, m)
If m & gt;=40:
Break
P. tart ()
P.j oin ()

CodePudding user response:

The pritn written to the main (), is not in the try
Call this, do not perform the if __name__=="__main__ '

CodePudding user response:

reference 1st floor weixin_45903952 response:
the pritn write a main (), is not in the try
Call this, do not perform the if __name__=="__main__ '

I want to know, is this module would not have to print, or am I here out of the other problems?

CodePudding user response:

refer to the second floor nangongxiaobai response:
Quote: refer to 1st floor weixin_45903952 response:

The pritn written to the main (), is not in the try
Call this, do not perform the if __name__=="__main__ '

I want to know, is this module would not have to print, or am I here out of the other problems?

When running this module, you can run the print here, while other references in this module, here is not to run,

CodePudding user response:

reference weixin_45903952 reply: 3/f
Quote: refer to the second floor nangongxiaobai response:

Quote: refer to 1st floor weixin_45903952 response:

The pritn written to the main (), is not in the try
Call this, do not perform the if __name__=="__main__ '

I want to know, is this module would not have to print, or am I here out of the other problems?

When running this module, you can run the print here, while other references in this module, here is not running,

Is my expression is not clear, this is my own to write a small example, I don't have any reference, any other documents also won't quote me this small example, I met the question is:
This file is only a function and a piece of code, why you can print the function, but not in my this code can be printed, I gradually carry out, also go the other print, but there is no any output on the console, ask trouble is originally this code inside of the print will not output, or I have other questions, thank you

CodePudding user response:

Def mian () :
P=the Process (target=f, args=(' Bob '))
M=0
While True:
M +=1
Time. Sleep (1)
Print (' m is % d, m)
If m & gt;=40:
Break
P. tart ()
P.j oin ()

If __name__=="__main__ ':
main()
  • Related