Home > other >  Encountered in the Python IndexError: list index out of range how to solve
Encountered in the Python IndexError: list index out of range how to solve

Time:09-29

Code is as follows:
GBK # coding=
The import socket
The import sys
S=socket. The socket (socket. AF_INET, socket. SOCK_DGRAM)
# assumes 192.168.0.103 is the IP address of the receiving end machine
S.s endto (sys. Argv [1]. The encode (), (5000) "192.168.0.103)
S.c lose ()
Error:
Traceback (the most recent call last) :
The File "C: \ Users \ admin \ eclipse - workspace \ 111 \ SRC \ 111. Py", line 6, the in & lt; module>
S.s endto (sys. Argv [1]. The encode (), (5000) "192.168.0.103)
IndexError: list index out of range
Excuse me, how to solve, thank you

CodePudding user response:

Sys. Argv [1]. Encode ()
System at compile time, meet the words will be an error

CodePudding user response:

Can try to write sys. (data type switch) (argv [1]). The encode ()

CodePudding user response:

Tip is list index out of range, you can print sys. First argv and see,
  • Related