मैं स्ट्रिंग आपरेशन का उपयोग करने के एक बहुत ही सरल python3 गाइड के माध्यम से जा रहा था और उसके बाद मैं इस अजीब त्रुटि का सामना किया:क्यों काम नहीं कर रहा है?
In [4]: # create string
string = 'Let\'s test this.'
# test to see if it is numeric
string_isnumeric = string.isnumeric()
Out [4]: AttributeError Traceback (most recent call last)
<ipython-input-4-859c9cefa0f0> in <module>()
3
4 # test to see if it is numeric
----> 5 string_isnumeric = string.isnumeric()
AttributeError: 'str' object has no attribute 'isnumeric'
समस्या यह है कि, जहाँ तक मैं बता सकता हूँ, str
DOES एक विशेषता है , isnumeric
।
नहीं अजगर 2 में, एक यूनिकोड स्ट्रिंग के लिए कि स्ट्रिंग बदल जाते हैं। –
इसके बजाय 'isdigit' का उपयोग करने का प्रयास करें। – sshashank124
उत्तर मिला: पाठ डिफ़ॉल्ट रूप से Py3 में यूनिकोड है। http://stackoverflow.com/questions/16863696/python-isnumeric-function-works-only-on-unicode?rq=1 – Anton