开发者

Python set not empty but pop returns empty? [closed]

开发者 https://www.devze.com 2023-03-07 10:25 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 1开发者_C百科1 years ago.

I saw a similar problem with multithreading but this isn't even multithreading, it's just straight up populating a set and then popping.

I print out the set and then immediately after, try to print out the pop of the set. but it says the set is empty when i see something like this for the set print out:

set(['', 'asdf', 'asdf, 'asdf'])


pop(...)
    Remove and return an arbitrary set element.
    Raises KeyError if the set is empty.

Since you have an empty string in your set, it is highly possible that a foo.pop() returns this empty string and printing an empty string gives you nothing.

0

精彩评论

暂无评论...
验证码 换一张
取 消