标签:orm 不执行 pytho out lis match list local pattern
1.下列输出可能不是“aa,bb”的是(B)
d0 = {"a":"aa","b":"bb"}
print("d0: {a},{b}".format(**d0))
d1 = {"aa","bb"}
print("d1: {0},{1}".format(*d1))
d2 = ["aa","bb"]
print("d2: {0},{1}".format(*d2))
d3 = ("aa","bb")
print("d3: {0},{1}".format(*d3))
#****输出结果*****
d0: aa,bb
d1: aa,bb
d2: aa,bb
d3: aa,bb
d0: aa,bb
d1: bb,aa # 随机输出
d2: aa,bb
d3: aa,bb
2.执行完下列代码后cnt的值等于几?()
import re
cnt = 0
pattern = "text"
if re.match(pattern,"text.tap"):
cnt += 1
if re.match(pattern,"tap.text"): #执行第一个就不执行第二个
cnt += 1
if re.search(pattern,"text.tap"):
cnt += 1
if re.search(pattern,"tap.text"):
cnt += 1
print(cnt)
#输出看结果:
# 3
3.执行完下列代码,最终的输出结果是多少?(D)
data_list = [1,2,3,4,5]
for i in data_list:
data_list.remove(i)
print(data_list)
A.[]
B.[1,3,4]
C.[2,5]
D.[2,4]
8.如下打印结果为:A
a = 1
def outdef():
def indef():****
nonlocal a
print(a)
a = 3
a = 2
indef()
print(a)
outdef()
print(a)
********分析**********
就近原则:
进入indef()的是a=2,打印之后被修改为3出来的a=3
**********************
A. 2 3 1
B. 1 2 3
C. 2 3 2
D. 1 3 1
标签:orm 不执行 pytho out lis match list local pattern
原文地址:https://www.cnblogs.com/korol7/p/13138499.html