猫史档案馆


【Python作品分享】海龟——文件创建器【作业帖】

用户:GhostSharkGhostShark查看:0 回复:0 评论:0 创建时间:2022-09-29T12:32:14


【作品展示】

center_image

 

【作品介绍】

随便做做

制作粗劣

若存在Bug请见谅(小白)

(本人亲测无Bug)

欢迎试用

 

【作品源代码】

def hanshu2():
    print('欢迎使用文件创建器!')
    a = input('''您确定要启动该程序吗?该程序可能会使您的电脑过热或内存不足;
输入‘确定’或‘queding’以启动该程序,输入‘取消’或‘quxiao’以退出:
''')
    if a == '确定':
        count = 1
        name = input('请输入文件名称:   ')
        A = input('请输入文件内容: ')
        B = input('请输入文件创建数量: ')
        C = input('请输入文件倍数(输入‘count’可使文件内容成倍增加): ')
        lujing = input('请输入文件地址( 默认:D:// ):  ')
        print('正在加载…………')
        print('加载完毕!')
        print('''<<<<<<>>>>>>''')
        print('正在创建文件…………')
        while count <= int(B):
            if lujing == '':
                wanzheng = 'D://' + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1
            elif lujing == '默认':
                wanzheng = 'D://' + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1
            else:
                wanzheng = lujing + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1

        else:
            print('创建完毕!')
            print('')
            print('')

            hanshu2()

    elif a == 'queding':
        count = 1
        name = input('请输入文件名称:  ')
        A = input('请输入文件内容: ')
        B = input('请输入文件创建数量: ')
        C = input('请输入文件倍数(输入‘count’可使文件内容成倍增加): ')
        lujing = input('请输入文件地址( 默认:D:// ):  ')
        print('正在加载…………')
        print('加载完毕!')
        print('正在创建文件…………')
        while count <= int(B):
            if lujing == '':
                wanzheng = 'D://' + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1
            elif lujing == '默认':
                wanzheng = 'D://' + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1
            else:
                wanzheng = lujing + str(name) + '-' + str(count) + '.txt'
                file = open(wanzheng, 'w')
                if C != 'count':
                    file.write(A * int(C))
                    file.close()
                    count = count + 1
                elif C == 'count':
                    file.write(A * count)
                    file.close()
                    count = count + 1


        else:
            print('创建完毕!')
            print('')
            print('')

            hanshu2()

    elif a == '取消':
        print(' ')

    elif a == 'quxiao':
        print(' ')



hanshu2()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页