Py学习  »  sanyash  »  全部回复
回复总数  3
6 年前
回复了 sanyash 创建的主题 » 在Python中测试回退导入

据我所知,您的结构如下:

- dir sandbox
-- file a.py
-- file b.py
-- file c.py
- file d.py

sys.modules['a'] = None sys.modules['sandbox.a'] = None 这很管用。

6 年前
回复了 sanyash 创建的主题 » 压缩元组的python列表理解
list_1 = [[1, 0, 0, 1], [0, 2, 0, 0]]
list_2 = [(1,'A'), (2,'B'), (3,'C'), (4,'D')]
list_3 = [
    [
        item
        for index, val in enumerate(elem) if val > 0
        for item in [list_2[index]] * val
    ]
    for elem in list_1
]
print(list_3)
# [[(1, 'A'), (4, 'D')], [(2, 'B'), (2, 'B')]]
6 年前
回复了 sanyash 创建的主题 » python:winerror 10045:引用的对象类型不支持尝试的操作

请参阅帮助(socket.send):

Help on built-in function send:

send(...) method of socket.socket instance
    send(data[, flags]) -> count

    Send a data string to the socket.  For the optional flags
    argument, see the Unix manual.  Return the number of bytes
    sent; this may be less than len(data) if the network is busy.

所以,这条线 s.send(message, key) 可能无法按您预期的方式工作:它只发送 message 具有 key 解释为标志,而不是两者 消息 钥匙 . 尝试发送 消息 钥匙 分别地。别忘了 recv 它们也是分开的。