A detailed explanation of the use of regular expressions in Python _python

Source: Internet
Author: User

If you use input and raw_input to read a file directly on the command line, and you want to take the file directly into the command line to handle it,

The input method can be handled directly, and if you want to use the Raw_input method, the address of the read file will be enclosed in quotation marks, and you will need to manually remove the quotes 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 ' 
  The Raw_input method: '/home/sunny/caffe-master/examples/images/cat.jpg ' 



In addition, for the two input methods another intuitive difference is the input of the processing function, that is, the input formula will directly output the results, and Raw_input will be authentic (raw) output:


  #! -*-coding:utf-8-*-  
  print raw_input (U ' Test raw_input:\n ') 
   
  print input (U ' Test 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.