gpt4 book ai didi

python - 当我运行我的套接字程序时,得到 : `import: command not found`

转载 作者:太空宇宙 更新时间:2023-11-04 04:14:39 26 4
gpt4 key购买 nike

<分区>

我写了一个套接字服务器程序员:

#-*- coding:utf-8 -*-
# Author:sele

import socket

HOST = '127.0.0.1'
PORT = 65432

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind((HOST, PORT))
s.listen()
conn, addr = s.accept()
with conn:
print('Connected by', addr)
while True:
data = conn.recv(1024)
if not data:
break

conn.sendall(data)

当我在我的命令中运行它时,出现错误:

sele-MacBook-Pro:test01 ldl$ ./tests02-server.py
./tests02-server.py: line 5: import: command not found
;; connection timed out; no servers could be reached
Error: Current platform "darwin 18" does not match expected platform "darwin 16"
Error: If you upgraded your OS, please follow the migration instructions: https://trac.macports.org/wiki/Migration
OS platform mismatch
while executing
"mportinit ui_options global_options global_variations"
Error: /opt/local/bin/PORT: Failed to initialize MacPorts, OS platform mismatch
./tests02-server.py: line 10: syntax error near unexpected token (' ./tests02-server.py: line 10: with socket.socket(socket.AF_INET,
socket.SOCK_STREAM) as s:'

为什么找不到import

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com