简体   繁体   English

Python中{str}和{str_}之间的区别

[英]difference between {str} and {str_} in Python

I am trying to debug a code in Python. 我正在尝试用Python调试代码。 When I go to debug mode and look at the variable word in a similar code that works fine, I see the type of this variable is shown as {str} , but in the other code that does not work correctly I see the type of word in the debugger is shown as {str_} . 当我进入调试模式并查看类似代码中的变量word工作正常时,我看到此变量的类型显示为{str} ,但在其他代码中无法正常工作我看到了word的类型在调试器中显示为{str_} What is the difference between these and how can I convert a variable type {str_} to a type {str} . 它们之间有什么区别?如何将变量类型{str_}转换为类型{str}

Here is part of the code: 以下是代码的一部分:

cv = CountVectorizer(min_df=1, charset_error="ignore", stop_words="english", max_features=200)
counts = cv.fit_transform([text]).toarray().ravel()
words = np.array(cv.get_feature_names())
...
for word, count in zip(words, counts):

I use PyCharm to debug, and it is in Python 3.3. 我使用PyCharm进行调试,它在Python 3.3中。

I appreciate any help on this. 我很感激任何帮助。

str is probably the builtin str . str可能是内置的str str_ is something else. str_是别的东西。 Perhaps a subclass of str ? 也许是str的子类? Hard to tell without seeing more 很难说没有看到更多

Edit: 编辑:

Looks like str_ may be numpy.str_ which is what you'll get if you pour a list of str into a numpy array 看起来str_可能是numpy.str_ ,如果你把一个str列表放到一个numpy数组中你会得到的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM