Questions tagged «createfile»

9
创建文件(如果不存在)
我正在尝试打开一个文件,如果该文件不存在,则需要创建该文件并将其打开以进行写入。到目前为止,我有: #open file for reading fn = input("Enter file to open: ") fh = open(fn,'r') # if file does not exist, create it if (!fh) fh = open ( fh, "w") 错误消息说在线上有问题if(!fh)。我可以exist在Perl中使用like吗?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.