Running subprocess on Windows causes TypeError: must be str without null characters or None, not str
Question: I'm trying to make a script that opens a program. I have a command that I
normally run manually in a Windows run (Windows Key + R).

    
    
    command "C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.54\deploy\League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"
    
    import subprocess
    subprocess.call('"C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.53\deploy\League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"')
    

When I run this, I get an error:

    
    
    Traceback (most recent call last):
      File "C:\Users\Duran\Desktop\helloworld.py", line 2, in <module>
        subprocess.call('"C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.53\deploy\League of Legends.exe" "8394" "LoLLauncher.exe" "" "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"')
      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)
    TypeError: must be str without null characters or None, not str
    

You probably already saw I'm pretty new to this but if someone could help me I
would really appreciate it.


Answer: `"\0"` is NUL character -- `ord('\0') == 0`. It leads to the `TypeError` in
your question.

Use `r"\0"` to get two symbols: the backslash plus the decimal zero --  
`list(map(ord, r'\0')) == [92, 48]`.

    
    
    from subprocess import check_call
    
    check_call([
        r"C:\Riot Games\League of Legends\RADS\solutions\lol_game_client_sln\releases\0.0.1.54\deploy\League of Legends.exe",
        "8394",
        "LoLLauncher.exe",
        "",
        "spectator 95.172.65.26:8088 kbbaZXzvdjwL2tHtX7XGaEG17tJQLVBa 945850509 EUN1"
    ])
    

Note: there are no quotes inside quotes.

