第一个调试成功的Python小程序

   上一周在电脑上安装Python 和Pycharm软件,在抖音上学习。抖音博主RIck小白课堂,有一些Python入门的课程,进行学习。

     有一节课程,关于文件中写字符的函数小程序,原程序如下:

def textCreate(name,msg):
desktopPath ='C:/Users/EDY/Desktop/'

fullPath = desktopPath + name +'.txt'

file = open(fullPath,'w')

file.write(msg) file.close()

print('done‘)


textCreate( name: 'hello', msg: 'hello wortd')

无法调试通过,各位大侠,请有时间指导一二。

通过查找资料和系统问题反馈和提示,讲程序修订如下:

import typing
def textCreate(name,msg):
    desktopPath ='C://Users//GJH2257//'
    fullPath = desktopPath + name +'.txt'
    file:typing.textIO = open(fullPath, 'w')
    print(fullPath)
    file.write(msg)
    file.close()
    print('done')
textCreate( 'hello',  'hello world')

调试成功,并能生成hello.txt文件,并能写入文字。十分开心。

另外,cfg库文件,一直无法安装成功,请高人指点指点,不甚感谢!

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值