发布网友 发布时间:2022-04-21 18:59
共3个回答
热心网友 时间:2023-05-19 04:04
# -*- coding: utf-8 -*-
"""
:created on: 2015年5月11日
:author: Chuanqing Qin
:contact: qinchuanqing918@163.com
"""
import string
def deal_file(row_count, column_count,file_name):
"""
do the job which you want.
:param: int column_count: how many column you want to output. which should <= 26
:param: int column_count: how many column you want to output.
:param: String file_name: in which file you want to output.
"""
with open(file_name, 'w') as f:
for index, row in enumerate(string.ascii_lowercase):
if row_count > 26:
break
for i in xrange(1, column_count):
row_temp = '%s%d' % (row, i)
f.write(row_temp)
f.write('\t')
row_temp = '%s%d' % (row, column_count)
f.write(row_temp)
f.write('\n')
if __name__ == '__main__':
deal_file(25, 3, 'twmp.txt')
热心网友 时间:2023-05-19 04:04
有疑问:
a1 a2 a3 b1 b2 ...是从哪里来, 数组还是临时输入?
你要求输出结果是4行3列?
追问这些数据只是举个例子,按照这样的格式输出即可,一列一列输出追答fp = open( 'file.txt', 'w')
fp.write(str(12))
fp.write('\t')
fp.write(str(34))
fp.write('\t')
fp.write(str(56))
fp.write('\n')
.......
fp.close()
热心网友 时间:2023-05-19 04:05
你的文档格式是怎么样的呢?追问txt里最普通的啊(gb2312),在乎这些干嘛?输出这样的结果就可以了
追答....................................................