python操作excel表格根据sheet,并且把这列每项内容转换成大写首字母
作者:互联网
# -*- coding:utf-8 -*- import openpyxl import pypinyin wb = openpyxl.load_workbook(r"D:\PythonCode\AfterInstalled\爬取共享平台\人口库设计20200419.xlsx") ws = wb.get_sheet_by_name('人口基准信息') data_dict = {"nodes": [], "links": []} for i in range(2, 50000): # 获取很多行,中间程序有中断 # xuqiu_bumen = ws.cell(row=i, column=3).value mulu = ws.cell(row=i, column=4).value # print(mulu) # print(mulu) if mulu == None: break a = pypinyin.pinyin(mulu, style=pypinyin.FIRST_LETTER) b = [] for i in range(len(a)): b.append(str(a[i][0]).upper()) c = ''.join(b) print(c)
标签:sheet,wb,python,pypinyin,首字母,ws,print,mulu 来源: https://www.cnblogs.com/Doner/p/12757822.html