[英]Int + Str type python
So I have this code所以我有这个代码
la = os.path.dirname(__file__)
with open(la, "/builds", "w") as python_script_file:
python_script_file.write(other_python_script)
My path contains letters and numbers:我的路径包含字母和数字:
storage/0/downloads...
And what should I do?我该怎么办? It says I need int when I make int it says str.
它说我需要 int 当我做 int 它说 str。
Error:错误:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 52, in <module>
TypeError: an integer is required (got type str)
[Program finished]
So it's a loop, I can't do anything I tried to search something, but it seems to be no one asked this before所以这是一个循环,我无法做任何事情我试图搜索一些东西,但似乎以前没有人问过这个
Have a look at the documentation of open .查看open 的文档。 you need the file name as the first argument (not first and second).
您需要文件名作为第一个参数(不是第一个和第二个)。
Use os.path.join
to join path segments to one:使用
os.path.join
将路径段连接到一个:
la = os.path.dirname(__file__)
fName = os.path.join(la,"builds")
with open(fName, "w") as python_script_file:
python_script_file.write(other_python_script)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.