You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def get_process_connections():
connections = psutil.net_connections(kind="inet")
for conn in connections:
process = psutil.Process(conn.pid)
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")
if name == "main":
get_process_connections()
This code was written by chatGPT to display the process names of all processes PID|Total amount of uploaded data|Total amount of downloaded data
But chatGPT mainly encounters this "conn.bytes_sent" and "conn.bytes_recv" will always report errors, how can I rewrite it?
error:
Traceback (most recent call last):
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 10, in
get_process_connections()
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 7, in get_process_connections
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")
AttributeError: 'sconn' object has no attribute 'bytes_sent'
The text was updated successfully, but these errors were encountered:
OS: { Windows 10 }
Architecture: { 64bit}
Psutil version: { 5.8.0 }
Python version: { python3.9.7}
import psutil
def get_process_connections():
connections = psutil.net_connections(kind="inet")
for conn in connections:
process = psutil.Process(conn.pid)
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")
if name == "main":
get_process_connections()
This code was written by chatGPT to display the process names of all processes PID|Total amount of uploaded data|Total amount of downloaded data
But chatGPT mainly encounters this "conn.bytes_sent" and "conn.bytes_recv" will always report errors, how can I rewrite it?
error:
Traceback (most recent call last):
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 10, in
get_process_connections()
File "C:\Users\Wang\PycharmProjects\pythonProject\main.py", line 7, in get_process_connections
print(f"{process.name()}|{conn.pid}|{conn.bytes_sent}|{conn.bytes_recv}")
AttributeError: 'sconn' object has no attribute 'bytes_sent'
The text was updated successfully, but these errors were encountered: