我正在尝试用python代码在我的云驱动器中创建一个文件。当我在这个位置创建文件“/Users/agauravdeep/Library/Mobile Documents/com~apple~CloudDocs/无标题.rtf “使用任何应用程序,它都可以工作,但通过代码,我到目前为止不成功(虽然没有错误),即使尝试了超级用户。在
代码非常简单
# -*- coding: utf-8 -*-
#!/usr/bin/python
from os.path import expanduser
def createBugsFileInitiallyIfNotPresent():
global bugsFileLocation
bugsFileLocation = expanduser("~")+"/Library/Mobile Documents/com~apple~CloudDocs/abc.txt"
if(os.path.isfile(bugsFileLocation)):
f = open(bugsFileLocation, 'w+')
f.write(" dddd ")
这很管用 另外,vi~/Library/Mobile\Documents/com~apple~CloudDocs/wen dang.txt但当我在路径上加上引号时,它就不起作用了。在
任何建议都会很有帮助。在
您正在检查文件是否存在,但您表示要创建它。如果计划创建新文件,请删除If语句:
相关问题 更多 >
编程相关推荐