欢迎光临散文网 会员登陆 & 注册

Python 源码

2022-09-02 09:46 作者:千面伊人丶  | 我要投稿

想要每周课程Python源码的大聪明,

关注、私信up主,up给发送源码文件。


递归:

__author__ = "Alex Li"


def calc(n):

    print(n)

    if int(n/2) >0:

        return calc( int(n/2) )

    print("->",n)


calc(10)

高阶函数:

集合:

进度条:

__author__ = "Alex Li"


import sys,time


for i in range(20):

    sys.stdout.write("#")

    sys.stdout.flush()

    time.sleep(0.1)

文件修改:

__author__ = "Alex Li"

import sys

f = open("yesterday2","r",encoding="utf-8")

f_new = open("yesterday2.bak","w",encoding="utf-8")


find_str = sys.argv[1]

replace_str = sys.argv[2]

for line in f:

    if find_str in line:

        line = line.replace(find_str,replace_str)

    f_new.write(line)

f.close()

f_new.close()





Python 源码的评论 (共 条)

分享到微博请遵守国家法律