输出不同
Topic source你好,input返回的是数值类型,如int,float raw_inpout返回的是字符串类型,string类型,你使用raw_input就可以了。 [root@vmware1 scripts]# cat hello.py
!/bin/python3
name = raw_input('please enter your name: ') print('hello,',name) [root@vmware1 scripts]# python hello.py please enter your name: taokey ('hello,', 'taokey')
输出带参数的语句我看到可以用这种
Name = raw_input('please enter your name:')
print "hello,", Name
然后打印结果就可以是
please enter your name:will
hello, will
- 1
名字的事情再说吧
1.>>> print('The quick brown fox', 'jumps over', 'the lazy dog')
输出结果为('The quick brown fox', 'jumps over', 'the lazy dog')
不是 The quick brown fox jumps over the lazy dog
2.>>> name = input()
在输入时:Michael 出错,如下 Traceback (most recent call last): File "<pyshell#54>", line 1, in <module> name = input() File "<string>", line 1, in <module> NameError: name 'Michael' is not defined
输入改成'Michael'(加上引号),就不会出错啦,为什么要加引号,还是错在别处?