input方法可以直接处理,而如果要采用raw_input的方法的话,读入文件地址会带有引号,还需要自己手动去掉引号才能处理文件。
在ipython中测试一下代码:(读入一个图片文件的地址字符串)
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'
对于两种输入方式另一个直观区别就是input自带运算处理功能,也就是输入算式的话会直接输出结果,而raw_input会原汁原味(raw)地输出: #! -*- coding:utf-8 -*- print raw_input(u'测试raw_input:\n') print input(u'测试input:\n')
其它正则相关codego.net/25/1/1/代码提供
在ipython中测试一下代码:(读入一个图片文件的地址字符串)
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'
对于两种输入方式另一个直观区别就是input自带运算处理功能,也就是输入算式的话会直接输出结果,而raw_input会原汁原味(raw)地输出: #! -*- coding:utf-8 -*- print raw_input(u'测试raw_input:\n') print input(u'测试input:\n')
其它正则相关codego.net/25/1/1/代码提供
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29971755/viewspace-1561322/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29971755/viewspace-1561322/