Explain the use of regular expressions in Python

Source: Internet
Author: User
If you read a file directly at the command line with input and raw_input, and want to take the file directly into the command line to handle it,

The input method can be processed directly, and if you want to use the Raw_input method, the read-in file address is quoted, and you need to manually remove the quotation marks to process the file.


Test the code in Ipython: (read the address string of a picture file)

   A = input ("Input a:\n")   print "The Input method:", a   B = raw_input ("Input b:\n")   print "The Raw_input method: ", b      input A:   '/home/sunny/caffe-master/examples/images/cat.jpg ' the   Input method:/home/sunny/ Caffe-master/examples/images/cat.jpg      input B:   '/home/sunny/caffe-master/examples/images/cat.jpg '   



In addition, another visual difference between the two input methods is that input has an arithmetic processing function, that is, the input calculation will directly output the results, and Raw_input will be original (raw) output:


  #! -*-coding:utf-8-*-    print raw_input (U ' Test raw_input:\n ')      

Test results:

  • 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.