Why do python code sometimes perform differently on the command line and in the Python shell?

Source: Internet
Author: User

Reply content:

First, as the answer above @ Kochau says, the shell's behavior is not exactly the same as the Python code

>>> for i in range(5):...     i... 01234
This example is very interesting, no invitation, let me answer it.

Using unfamiliar functions and the library is dangerous.
Using unfamiliar functions and the library is dangerous.
Using unfamiliar functions and the library is dangerous.
The important words are three times.

First of all, look at this example, just to change the helloworld.cpp slightly, the main think this code should output what results?
#include 
   
    #include 
   
    usingnamespacestd;intmain(){    cout<<printf("asdf")<<endl;}
mainly because this thing has changed. Mainly because this thing has changed.
The standard output in the C library did not change.
Specifically, you can read this article / http ELI.THEGREENPLACE.NET/2 015/redirecting-all-kinds-of-stdout-in-python/
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.