Python3:按照不同的系统进行文件的追加编写

import platform

if 'Windows' in platform.system():
    xxx_file = 'E:/tmp/xxx_file.txt'
elif 'Linux' in platform.system():
    xxx_file = '/tmp/xxx_file.txt'
with open(xxx_file , 'w', encoding='utf-8') as foo:
    foo.write('true')

猜你喜欢

转载自blog.csdn.net/shunzi2016/article/details/108460447