关于Python文件读入
  • 板块学术版
  • 楼主entity
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/4/16 22:23
  • 上次更新2023/10/23 18:13:58
查看原帖
关于Python文件读入
225964
entity楼主2023/4/16 22:23

科技周写Python项目想从本地文档读入的时候用这段代码直接把窗口搞崩了,有人能来看看吗qwq

def fileRead():
    file=open("map.txt","r");
    tmp="w";
    isIn=False;
    isNum=True;
    ret="0";
    global fileCnt;
    while tmp!=" " and tmp!="\n":
        fileCnt+=1;
        file.read(fileCnt);
        if isIn==False:
            ret=tmp;
            isIn=True;
            continue;
        if (not '0'<=tmp<='9'):
            isNum=False;
        ret=ret+tmp;
    if isNum:
        ret=int(ret);
    file.close();
    return ret;
2023/4/16 22:23
加载中...