[email protected] 在 2022年12月20日 星期二中午12:35:52 [UTC+8] 的信中寫道:
> On 12/19/22, Jach Feng <[email protected]> wrote:
> >
> > That's really good for Linux user! How about Windows?
> In CMD, typing the "^" escape character at the end of a line ignores
> the newline and prompts for "more" input. If you press enter again,
> you'll get another "more" prompt in which you can write the rest of
> the command line. Command-line arguments are separated by spaces, so
> you have to start the next line with a space if you want it to be a
> new argument. Also, "^" is a literal character when it's in a
> double-quoted string, which requires careful use of quotes. For
> example:
>
> C:\>py -c "import sys; print(sys.orig_argv[3:])" spam^
> More?
> More? eggs^
> More?
> More? " and spam"
> ['spam\n', 'eggs\n and spam']
>
> The above is easier in PowerShell, which supports entering multiline
> strings without having to escape the newline. The second-level prompt
> is ">> ". For example:
>
> > py -c "import sys; print(sys.orig_argv[3:])" spam"
> >> " eggs"
> >> and spam"
> ['spam\n', 'eggs\n and spam']
Thanks for the information. No idea Windows CMD can take such a trick to enter
"\n" :-)
--
https://mail.python.org/mailman/listinfo/python-list