Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีเช็คว่า Unicode String มีเฉพาะ Numeric Characters ใน Python

ใช้ isnumeric() สำหรับ unicode strings

ตัวอย่าง

>> u"1234".isnumeric()
True
>>> u"1,a234".isnumeric()
False

แตกต่างจาก isdigit() ที่ทำงานกับ ASCII digits เท่านั้น