python用print()函数输出田字格示例代码如下:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Python用print()函数输出田字格
row = ”
for i in range(1, 12):
for j in range(1, 12):
if i in (1, 6, 11):
if j in (1, 6, 11):
row = row + ‘+’ + ‘ ‘
else:
row = row + ‘–‘ + ‘ ‘
else:
if j in (1, 6, 11):
row = row + ‘|’ + ‘ ‘
else:
row = row + ‘ ‘ + ‘ ‘
row = row + ‘\n’
print row