Python's print

Source: Internet
Author: User
Tags python script

The difference between the single quotation mark ', the double quotation mark ", the three quotation mark" "" "" "

1, single and double quotation marks are used for a reference to a string, where using double quotation marks when you need to wrap the line character "\", but when using three quotation marks (multi-quotes), you do not need to use a line character, in addition to the three quotation marks can use the note (#).

Print "Hello, world!" Print "Hello, world!" Print "" "Hello, World!" "" Print "" "Hello, #first Python script world!" "

2. Single quotes and double quotes are indistinguishable from string references, avoiding the use of escape symbols when using double quotation marks when double quotes are used, and using single quotes more succinctly and aesthetically. Single quotes are also true.

Print "I am here!" print ' I\ ' am here! ' print ' You said ' YES '. ' print "You said \" Yes\ "."

Ii. differences between raw_input () and input ()

1, when the input is a pure number

    • Input returns a numeric type, such as Int,float

    • Raw_inpout return String type, String type

2. Input string is an expression

Input computes the numeric expression in the string, and Raw_input does not.

If you enter "5 + 3":


      • Input will get an integer 8

      • Raw_input will get the string "5 + 3"

In fact:

def input (Prompt): Return (eval (raw_input (prompt)))

Three

1, accepts the input does not have the line to need to add the comma (,)

Print "Do you know Python?", Anw = Raw_input () print "Yes,you got it?" Anw1=raw_input ()

2,%r replace the original character content, do not explain

A = "abc" print "Frist var test a is%r"% aprint "Frist var test A is%s"% a

This article from the "Down-to-earth, pragmatic" blog, please be sure to keep this source http://3633188.blog.51cto.com/3623188/1610322

Python print

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.