本项目采用的是https://github.com/Yixiaohan/show-me-the-code中所提供的练习项目,所有代码均为原创,转载请注明,谢谢。
问题描述:将txt中的数字写入xls中。其具体代码如下:
import xlsxwriter, json
def json2xls():
wb = xlsxwriter.Workbook('numbers.xls')
ws = wb.add_worksheet("numbers")
with open('./a.txt') as f:
data = json.load(f)
for i in range(len(data)):
for j in range(len(data[i])):
ws.write(i, j, data[i][j])
wb.close()
if __name__=='__main__':
json2xls()
详细代码和结果,可以参考https://github.com/g8015108/exercise-for-python