python daily question每日一题 (#3)
python daily question每日一题 (#3)
kvps = { '1' : 1, '2' : 2 }
theCopy = kvps.copy()
kvps['1'] = 5
sum = kvps['1'] + theCopy['1']
print(sum)
上述代码的输出结果是?()
A. 1
B. 2
C. 6
D. 10
E. 抛出异常
kvps = { '1' : 1, '2' : 2 }
theCopy = kvps.copy()
kvps['1'] = 5
sum = kvps['1'] + theCopy['1']
print(sum)
What's the output of the code above? ()
A. 1
B. 2
C. 6
D. 10
E. An exception is thrown
(#2)答案
C,由于argv[0]输出的是文件的路径,因此参数从argv[1]开始算起,因此v2是argv[2]。
以上图代码为例,文件是1.py 我们python 1.py v1 v2, 下图是输出结果
可以看出v0 print出了文件的路径 1.py
(#2)Answer
C. as argv[0] represents the path of the program, so v1 is argv[1], v2 is argv[2].
For example, we programe 1.py as the picture above. And we type the command 'python 1.py v1 v2', the outputs are '1.py v1 v2'.
新人写文章,感谢各位大佬点赞~
As a new comer, I need your upvote :)