Py学习  »  Luke  »  全部回复
回复总数  5
2 年前
回复了 Luke 创建的主题 » 如何固定git?[重复]

你可以尝试多次。我遇到了这个问题,最后把它推到了GitHub。

2 年前
回复了 Luke 创建的主题 » Python:For循环只迭代一次——也使用with语句

在这一行使用return语句时: return file, text2 ,你退出for循环,跳过你想阅读的其他pdf。

解决方案是将return语句移到for循环之外。

6 年前
回复了 Luke 创建的主题 » 如何在python中使用程序集[duplicate]
5 年前
回复了 Luke 创建的主题 » Python:为什么散列函数不是确定性的?

在这种情况下,可能最容易定义自己的 __eq__ 功能和 __hash__ 功能。这将每次为您返回相同的哈希值:

class Generic:
    def __init__(self, id, name, property):
        self.id=id
        self.name = name
        self.property = property

    def __eq__(self, other):
        assert self.__class__ == other.__class__, "Types do not match"
        return self.id == other.id and self.name == other.name and self.property == other.property

    def __hash__(self):
        return hash ( (self.id, self.name, self.property) )

这还将使等效对象的散列相等,以及:

>>>obj = Generic(1, 'blah', 'blah')
>>>obj2 = Generic(1, 'blah', 'blah')
>>>obj == obj2
True
>>>hash(obj) == hash(obj2)
True

希望能有帮助!

5 年前
回复了 Luke 创建的主题 » git p4 clone命令给出错误:访问仓库失败:无法连接

Git-P4从未使用过python3。我一直在努力使它发挥作用-你可以在这里看到我目前的尝试:

https://github.com/luked99/git/tree/git-p4-python3-final-showdown

它仍然需要相当多的工作,但是一些测试已经开始通过了。不过,大多数还是失败了。