python 中 OS 模块中的格式化字符串问题

Problem with formated string in OS modul in python

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

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

问题是我关闭了字符串并可以将它与字符串和临时文件放在一起我的意思是它不起作用

错误:

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

试试看:

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

您可以只使用

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

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