Word中将一级标题设置为段前一行与段后一行时,不显示段前一行怎么办?

Word中将一级标题设置为段前一行与段后一行时,不显示段前一行怎么办?

  1. 把一级标题所在页称为当前页。

在这里插入图片描述

2.把光标定位在上一页的最后一行。
在这里插入图片描述

3.点击“布局”——“分隔符”——“分节符 下一页”。
在这里插入图片描述

4.把标题剪切、粘贴过来即可。
在这里插入图片描述

要在生成的CSV文件中将数值为0的字替换为空字符串,可以在写入每一行数据进行判断和替换。具体来说,可以在写入每个值之检查该值是否为0,如果是0,则将其替换为空字符串。以下是修改后的代码片: ```python if __name__ == '__main__': inPath = 'F:\\AWenXianTiQu\\SomePathFile-18\\JavaResult' dicPath = 'F:\\AWenXianTiQu\\SomePathFile-18\\dic-namecheck' outCsvName = 'F:\\AWenXianTiQu\\SomePathFile-18\\18-01.csv' odinaryDicFilename = dicPath + '/' + 'DicOdinary_0802.txt' radioDicFilename = dicPath + '/' + 'DicRatio_0802.txt' conditionDicFilename = dicPath + '/' + 'DicCondition.txt' normalizedFilename = dicPath + '/' + '0511.txt' material_word = ReadDicFile(odinaryDicFilename) materialRadio_word = ReadDicFile(radioDicFilename) condition_word = ReadDicFile(conditionDicFilename) formula_word = ReadDicFile(normalizedFilename) outFile = open(outCsvName, 'w', encoding='utf-8-sig') # 写入表头 outFile.write('filename') for type in material_word: outFile.write(',%s,%s,%s' % (type + '_name1', type + '_quantity1', type + '_unit1')) outFile.write(',%s,%s,%s' % (type + '_name2', type + '_quantity2', type + '_unit2')) outFile.write(',%s,%s,%s' % (type + '_name3', type + '_quantity3', type + '_unit3')) for type in materialRadio_word: outFile.write(',%s,%s' % ('R_' + type + '_name1', 'R_' + type + '_quantity1')) outFile.write(',%s,%s' % ('R_' + type + '_name2', 'R_' + type + '_quantity2')) outFile.write(',%s,%s' % ('R_' + type + '_name3', 'R_' + type + '_quantity3')) for type in condition_word: outFile.write(',%s,%s,%s,%s' % (type + '_tempNumber', type + '_tempUnit', type + 'timeNumber', type + 'timeUnit')) outFile.write(',%s,%s,%s,%s,%s,%s,%s,%s' % ('cry1_tempNumber', 'cry1_tempUnit', 'cry1_timeNumber', 'cry1_timeUnit', 'cry2_tempNumber', 'cry2_tempUnit', 'cry2_timeNumber', 'cry2_timeUnit')) outFile.write(',check_condition,pH,product,uncategorizes') outFile.write('\n') xmlFilepaths = GetFilenames(inPath, 'xml') for filepath in xmlFilepaths: try: uncategorizes = [] filename = GetDOIFilename(filepath) with open(filepath, 'r', encoding='utf-8-sig') as file: content = file.read() content = modified_xml(content) pH = ExtractSolutionpH(content) product = ExtractProduct(content) material_quantity, material_unit, material_percent = ExtractMaterials(content) material_ratio1 = ExtractMaterialRatios1(content) material_ratio2 = ExtractMaterialRatios2(content) reactionMaterials = ClassfyMaterials(material_quantity, material_unit, material_word, material_percent) if len(material_ratio1) >= len(material_ratio2): reactionMaterialRatios = ClassfyMaterialsRatio(material_ratio1, materialRadio_word) else: reactionMaterialRatios = ClassfyMaterialsRatio(material_ratio2, materialRadio_word) actionPhraseType_condition = ExtractCondition(content) actionPhraseType_conditionPL = ExtractConditionPL(content) actionPhraseType_conditionChecks = ExtractConditionCheck(content) actionPhraseType_conditionCheck1 = [] list_condition = [str(x) for x in actionPhraseType_condition.values()] list_conditionPL = [str(x) for x in actionPhraseType_conditionPL] try: for condition in actionPhraseType_conditionChecks: condition = str(condition) if condition not in list_condition and condition not in list_conditionPL: actionPhraseType_conditionCheck1.append(condition) actionPhraseType_conditionChecks = actionPhraseType_conditionCheck1 except: pass outFile.write(filename) for type in material_word: outFile.write(',%s,%s,%s' % ( '' if reactionMaterials[type + '_name1'] == '0' else reactionMaterials[type + '_name1'].replace(',', ';').replace('(%', ''), '' if reactionMaterials[type + '_quantity1'] == '0' else reactionMaterials[type + '_quantity1'], '' if reactionMaterials[type + '_unit1'] == '0' else reactionMaterials[type + '_unit1'] )) outFile.write(',%s,%s,%s' % ( '' if reactionMaterials[type + '_name2'] == '0' else reactionMaterials[type + '_name2'].replace(',', ';').replace('(%', ''), '' if reactionMaterials[type + '_quantity2'] == '0' else reactionMaterials[type + '_quantity2'], '' if reactionMaterials[type + '_unit2'] == '0' else reactionMaterials[type + '_unit2'] )) outFile.write(',%s,%s,%s' % ( '' if reactionMaterials[type + '_name3'] == '0' else reactionMaterials[type + '_name3'].replace(',', ';').replace('(%', ''), '' if reactionMaterials[type + '_quantity3'] == '0' else reactionMaterials[type + '_quantity3'], '' if reactionMaterials[type + '_unit3'] == '0' else reactionMaterials[type + '_unit3'] )) for type in materialRadio_word: try: outFile.write(',%s,%s' % ( '' if reactionMaterialRatios['R_' + type + '_name1'] == '0' else reactionMaterialRatios['R_' + type + '_name1'].replace(',', ';').replace('(%', ''), '' if reactionMaterialRatios['R_' + type + '_quantity1'] == '0' else reactionMaterialRatios['R_' + type + '_quantity1'] )) outFile.write(',%s,%s' % ( '' if reactionMaterialRatios['R_' + type + '_name2'] == '0' else reactionMaterialRatios['R_' + type + '_name2'].replace(',', ';').replace('(%', ''), '' if reactionMaterialRatios['R_' + type + '_quantity2'] == '0' else reactionMaterialRatios['R_' + type + '_quantity2'] )) outFile.write(',%s,%s' % ( '' if reactionMaterialRatios['R_' + type + '_name3'] == '0' else reactionMaterialRatios['R_' + type + '_name3'].replace(',', ';').replace('(%', ''), '' if reactionMaterialRatios['R_' + type + '_quantity3'] == '0' else reactionMaterialRatios['R_' + type + '_quantity3'] )) except: print(type) for type in condition_word: if type in actionPhraseType_condition: condition = actionPhraseType_condition[type] outFile.write(',%s,%s,%s,%s' % ( '' if condition[0] == '0' else condition[0], '' if condition[1] == '0' else condition[1], '' if condition[2] == '0' else condition[2], '' if condition[3] == '0' else condition[3] )) else: outFile.write(',%s,%s,%s,%s' % ('', '', '', '')) for condition in actionPhraseType_conditionPL: outFile.write(',%s,%s,%s,%s' % ( '' if condition[0] == '0' else condition[0], '' if condition[1] == '0' else condition[1], '' if condition[2] == '0' else condition[2], '' if condition[3] == '0' else condition[3] )) check_condition = actionPhraseType_conditionChecks outFile.write(',' + str(check_condition).replace(',', ';') + ',' + str(pH) + ',' + product.replace(',', ';') + ',' + str(uncategorizes).replace(',', ';') + '\n') except Exception as e: print(traceback.print_exc()) print(filename) outFile.close() ``` 在这个修改后的代码中,每次写入一个值都会检查该值是否为`0`,如果是`0`则替换为空字符串`''`。这样可以确保最终生成的CSV文件中会出现数值为0的字
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值