V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  lailongmen  ›  全部回复第 1 页 / 共 1 页
回复总数  4
@hubqin 谢谢!可以了。

@xpresslink 你这个方法不行啊。我是新手在看教学,只会这个办法。
教学里面是固定内容,比如:re.findall(r"hi", text)
感觉那样太死板,所以自己改成变量。
@maxoxo 谢谢,刚测试了,你这个方式也可以。
@manzhiyong 谢谢,搞定了。py3 也支持
@janxin 我看了这个文档,是说 w+读写都可以? http://www.runoob.com/python/python-func-open.html
而且就算我改成 r+,也还是无效。

f = open('C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32\\my\\game.txt', 'r+')
score1=f.read()
f.close()
if score1==bool(False):
f = open('C:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python36-32\\my\\game.txt', 'w+')
f.write('0 0 0')
f.close()
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2793 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 14ms · UTC 11:47 · PVG 19:47 · LAX 04:47 · JFK 07:47
Developed with CodeLauncher
♥ Do have faith in what you're doing.