小编Fae*_*rgn的帖子

Region:IOError:[Errno 22]无效模式('w')或文件名

我不知道为什么,但出于某种原因,每当我在输出文件的文件名中有"region"时,它就会给我这个错误:

IOError:[Errno 22]无效模式('w')或文件名:'path\regionlog.txt'

它为"region.txt","logregion.txt"等执行此操作.

class writeTo:
    def __init__(self, stdout, name):
       self.stdout = stdout
       self.log = file(name, 'w') #here is where it says the error occurs

output = os.path.abspath('path\regionlog.txt')
writer = writeTo(sys.stdout, output) #and here too
Run Code Online (Sandbox Code Playgroud)

为什么是这样?我真的想将我的文件命名为"regionlog.txt",但它不断出现这个错误.有办法解决吗?

python ioerror

21
推荐指数
1
解决办法
5万
查看次数

如何让python程序运行而不是在记事本中打开?

我无法打开.py文件。我有一个调用此.py文件的程序(即pathname / example.py file.txt),但不是运行python程序,而是在记事本中打开它。我如何运行它?

程序本身会接收一个文件,并创建一个更具可读性的输出。

编辑:操作系统是Windows7。正在调用python的文件是.bat文件。

编辑2:看起来由于某种原因我不得不重新安装python ...但看起来终于可以了。为何一开始就不会想到重新安装……然后我不得不更改文件扩展名的打开方式。多谢你们

python notepad

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

python ×2

ioerror ×1

notepad ×1