美文网首页
Udacity_Python程序算例之使用函数

Udacity_Python程序算例之使用函数

作者: 平平又无奇 | 来源:发表于2017-10-08 11:07 被阅读7次

    让浏览器休息一段时间

    import time
    import webbrowser
    total_breaks = 3
    break_count = 0
    print("This program started on " +time.ctime())
    print("This program started on " +time.ctime())
    while(break_count<total_breaks):
        time.sleep(10)
        webbrowser.open("http://www.jianshu.com/u/9b991ae9b682")
        break_count = break_count + 1
    

    批量去掉文件名称中的数字

    import os
    def rename_files():
        file_list = os.listdir(r"D:\python\tut")
        saved_path = os.getcwd()
        print("Current Working Directory is" +saved_path)
        os.chdir(r"D:\python\tut")
        for file_name in file_list:
            os.rename(file_name,file_name.translate(None,"0123456789"))
        os.chdir(saved_path)
    rename_files()
    

    相关文章

      网友评论

          本文标题:Udacity_Python程序算例之使用函数

          本文链接:https://www.haomeiwen.com/subject/oeaojxtx.html