python中操作系统模块中格式化字符串的问题



我需要帮助解决这个问题:

temp = "video.mp4"
way_to_file = r"C:UsersLukasDesktopauto youtube channel" + temp

问题是我关闭了字符串,可以把它放在一起,字符串和temp我的意思是它不工作

错误:

Traceback (most recent call last):
File "<pyshell#42>", line 1, in <module>
subprocess.call(['hello.py', 'htmlfilename.htm'])
File "C:Python34libsubprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "C:Python34libsubprocess.py", line 858, in __init__
restore_signals, start_new_session)
File "C:Python34libsubprocess.py", line 1111, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

您可以只使用

way_to_file = f"C:\Users\Lukas\Desktop\auto youtube channel\{temp}"

way_to_file = rf"C:UsersLukasDesktopauto youtube channel{temp}"

改为尝试:

temp = "video.mp4"
way_to_file = "C:\Users\Lukas\Desktop\auto youtube channel\" + temp

最新更新