python调用另一个文件自定义函数_python,如何使用自定义函数来写进另一个文件...

匿名用户

1级

2016-01-27 回答

with无问题,你的open省略了模式后,默认为读r,当然没法写了。

open(name[, mode[,

buffering]])

Open a file, returning an object of the file

type described in section File Objects. If the file

cannot be opened, IOError

is raised. When opening a file, it’s preferable to use open()

instead of invoking the file constructor directly.

The first two arguments are the same as for stdio‘s fopen():

name is the file name to be opened, and mode is a string

indicating how the file is to be opened.

The most commonly-used values of mode are 'r' for reading, 'w' for writing (truncating

the file if it already exists), and 'a' for appending (which on some Unix systems

means that all writes append to the end of the file regardless of the

current seek position). 【If mode is omitted, it defaults to 'r'.】

追问:

with open('man_data.txt') as mf :

原来您说的是这里。

可是man_data.txt文件我又不动啊?

追答:

open("man_data.txt","w“)不久可以了吗?

追问:

从新来个例子:

data = open("case.txt")

比如case.txt里面是['a', 'b', 'c']我想把case里的文件复制到case2.txt中,并且这样显示:

a

b

c如何写print_lol语句啊?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值