Python Data Representation 【Week 4 Exercise】:Practice Project: Updating the CodeSkulptor Docs

这是一个关于Python数据表示的实践项目,涉及更新CodeSkulptor文档。在这个项目中,作者经历了长时间的调试过程,提升了自己的技能。
摘要由CSDN通过智能技术生成

Practice Project: Updating the CodeSkulptor Docs

debug了好久的我实在是太菜了..

"""
Week 4 practice project template for Python Data Representation
Update syntax for print in CodeSkulptor Docs
from "print ..." syntax in Python 2 to "print(...)" syntax for Python 3
"""

# HTML tags that bounds example code
PREFIX = "<pre class='cm'>"
POSTFIX = "</pre>"
PRINT = "print"


def update_line(line):
    """
    Takes a string line representing a single line of code
    and returns a string with print updated
    """
    #如果行内容中找不到print直接返回,找到print先存留前面的缩进内容
    if line.find(PRINT)!=-1:
        first_part = line[0:line.find("print")]
    else:
        return line

    # Strip left white space using built-in string method lstrip()
    string = line.lstrip(" ")
    # If line is print stat
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值