简体   繁体   中英

socket.connect question about parenthesis in python

I have been starting out with python over the past 8 months. I know I'm just at the start of my journey, and this is the first programming language that I have been working with.

I am currently playing around with socket. My question is simple, why do I need double parenthesis sock.connect((ipaddress, port)), to get my program to work?

import socket
#from IPy import IP
 
ipaddress = input("Enter target to scan: ")
port = 80
 
#Esablish a connection to a port using socket
try:
    sock = socket.socket()
    sock.connect((ipaddress, port))
    print("[+] Port 80 is open: ")
except:
    print("[-] Port 80 is closed: ")

I have been starting out with python over the past 8 months. I know I'm just at the start of my journey, and this is the first programming language that I have been working with.

I am currently playing around with socket. My question is simple, why do I need double parenthesis sock.connect((ipaddress, port)), to get my program to work?

import socket
#from IPy import IP
 
ipaddress = input("Enter target to scan: ")
port = 80
 
#Esablish a connection to a port using socket
try:
    sock = socket.socket()
    sock.connect((ipaddress, port))
    print("[+] Port 80 is open: ")
except:
    print("[-] Port 80 is closed: ")

I have been starting out with python over the past 8 months. I know I'm just at the start of my journey, and this is the first programming language that I have been working with.

I am currently playing around with socket. My question is simple, why do I need double parenthesis sock.connect((ipaddress, port)), to get my program to work?

import socket
#from IPy import IP
 
ipaddress = input("Enter target to scan: ")
port = 80
 
#Esablish a connection to a port using socket
try:
    sock = socket.socket()
    sock.connect((ipaddress, port))
    print("[+] Port 80 is open: ")
except:
    print("[-] Port 80 is closed: ")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM