无法写入文本文件输入要写入的文本

时间:2015-10-24 00:33:06

标签: python python-3.x

所以我想写这个:

pMessage = message.content.replace('!createpoll ', '')
newP = pMessage.split()
countforpoll = 0

for p in newP:
    if countforpoll == 0:
        countforpoll = 1
        pollName = p
    elif ('END' == p) == False:
        try:
            with open("poll.txt",'a') as f:
                f.write(str(p +' 0\n'))
        except EnvironmentError as e:
            print("Error:", e)

但它根本没有写入空文本文件 !createpoll具有格式

!createpoll (name of poll) (as many options) (END to let the program know youre finished)

message.content是一个包含个人信息的字符串。

0 个答案:

没有答案