相关疑难解决方法(0)

从Python中打开文件获取路径

如果我有一个打开的文件,是否有os调用将完整路径作为字符串?

f = open('/Users/Desktop/febROSTER2012.xls')
Run Code Online (Sandbox Code Playgroud)

f,我怎么得到"/Users/Desktop/febROSTER2012.xls"

python

100
推荐指数
4
解决办法
7万
查看次数

Python - 如何使用%s修改文本输出?

非常直接给你们,但你如何修改%s的输出值?

print "Successfully created the file: %s" % iFile + '.txt'
Run Code Online (Sandbox Code Playgroud)

我尝试使用()的,{}的,但没有什么工作?

iFile是文件的名称,我希望它在显示时以.txt显示.

编辑:

我得到了输出 Successfully created the file: <open file 'test', mode 'rb' at 0x14cef60>.txt

python string

-1
推荐指数
1
解决办法
156
查看次数

标签 统计

python ×2

string ×1