嵌套对比
def as_view():
print("1\n")
def view():
print("2\n")
return view;
a=as_view
a()()
#include<iostream>
using namespace std;
auto as_view()
{
cout<<"1\n";
auto view = []() // 使用Lambda函数定义a,c++嵌套真这样做
{
cout<<"2\n";
};
return view;
}
int main()
{
auto (*a)()=as_view;//函数指针
a()();
system("pause");
return 0;
}
循环方法
for row in matrix: # row是每一行的list
for element in row:
print(element, end=' ')
print() # 换行
for a, b in matrix:
print(a, b)
for i in range(len(matrix)):
for j in range(len(matrix[0])):
print(matrix[i][j])