python创建不了特定的文件名 求助
boy=['我和男的','我的密码3344','我的银行卡2234343']girl=['我和我女的','我的密码78998','我的银行卡58995']
fileboy='男.txt'
filegirl='女.txt'
boy_file=open('F:/python/fileboy','w')
girl_file=open('F:/python/filegirl','w')
boy_file.writelines(boy)
girl_file.writelines(girl)
boy_file.close()
girl_file.close()
定义了fileboy='男.txt'、filegirl='女.txt' 为什么 新建的文件名是 fileboy、filegirl
? boy_file=open('F:/python/fileboy','w')
改为
boy_file=open('F:/python/‘+fileboy,'w') 试试这样:
boy = ['我和男的', '我的密码3344', '我的银行卡2234343']
girl = ['我和我女的', '我的密码78998', '我的银行卡58995']
fileboy = '男.txt'
filegirl = '女.txt'
boy_file = open('F:/python/' + fileboy, 'w')
girl_file = open('F:/python/' + filegirl, 'w')
boy_file.writelines(boy)
girl_file.writelines(girl)
boy_file.close()
girl_file.close()
页:
[1]