文档提取函数格式

with open("word.txt",'r') as f:                                 # 打开文件
    new_file_list=[]
    for line in f.readlines():                                  # 遍历文件行,并切片
        if line!='\n':
            line_list=line.split()
            if line_list[0]=='def':

                for list_ob in line_list:                        # 遍历单词块,将需要部分插入列表
                    if list_ob=='#':
                        break                             # 'aaaddddffff'[2:6]!!!!!!!!
                    if list_ob!='def':
                        new_file_list.append(list_ob)
                        new_file_list.append(' ')
                new_file_list.append('\n\n\n')


with open('nword.txt','w') as f:
    for ob in new_file_list:                                      # 遍历列表,写入新文档
        f.write(ob)

文档:

def format(self, *args, **kwargs): # known special case of str.format
"""
S.format(*args, **kwargs) -> str

Return a formatted version of S, using substitutions from args and kwargs.
The substitutions are identified by braces ('{' and '}').
"""
pass

def format_map(self, mapping): # real signature unknown; restored from __doc__
"""
S.format_map(mapping) -> str

Return a formatted version of S, using substitutions from mapping.
The substitutions are identified by braces ('{' and '}').
"""
return ""

def index(self, sub, start=None, end=None): # real signature unknown; restored from __doc__
"""
S.index(sub[, start[, end]]) -> int

Like S.find() but raise ValueError when the substring is not found.
"""
return 0

新文档:

format(self, *args, **kwargs):


format_map(self, mapping):


index(self, sub, start=None, end=None):

 

转载于:https://www.cnblogs.com/wmxuan/p/7513112.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值