Sử dụng len() là phương pháp chung nhất để kiểm tra chuỗi có độ dài bằng không. Mặc dù nó bỏ qua thực tế là một chuỗi chỉ có khoảng trắng cũng thực tế được coi là chuỗi rỗng ngay cả khi nó khác không Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No2
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 ['yes']0_______30_______1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9
['yes']7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The string is empty.0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 The string is empty.7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 ['yes']0_______30_______1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 Đầu ra The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No Phương pháp #2. sử dụng không toán tử not cũng có thể thực hiện tác vụ tương tự như len() và kiểm tra chuỗi có độ dài 0, nhưng giống như ở trên, nó coi chuỗi chỉ có khoảng trắng cũng không trống, điều này thực tế không đúng. Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No1 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty6
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______10_______3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9
['yes']7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______40_______0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No17 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 Đầu ra The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No Phương pháp #3. Sử dụng not + str. dải() Vấn đề về chuỗi trống + độ dài bằng 0 có thể được loại bỏ bằng cách sử dụng dải (), dải () trả về true nếu nó gặp khoảng trắng, do đó việc kiểm tra nó có thể giải quyết vấn đề kiểm tra chuỗi hoàn toàn trống. Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No32
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______10_______3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No50 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No52 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No65 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______40_______0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No75 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No77 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 Đầu ra The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes Phương pháp #4. Sử dụng not + str. không gian Hoạt động theo cách tương tự như phương pháp trên và kiểm tra khoảng trắng trong chuỗi. Phương pháp này hiệu quả hơn bởi vì, dải () yêu cầu thực hiện thao tác dải cũng cần tải tính toán, nếu không. không gian có số lượng tốt Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No90 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No92
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______10_______3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No50 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes13 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No65 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2_______40_______0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes4 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7_______10_______2 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No75 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes39 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes8_______10_______9 ['yes']0 ['yes']1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 ['yes']5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 Đầu ra The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes Phương pháp. Sử dụng hiểu danh sáchPython3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes52_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes55 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes57 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes58 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes61 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes3 ['yes']0 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes64 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes65 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes67 Đầu ra ['yes'] Phương pháp. Sử dụng boolMột cách tiếp cận là sử dụng hàm bool. Hàm bool trả về Sai cho chuỗi rỗng và True cho chuỗi không trống Đây là một ví dụ về việc sử dụng hàm bool để kiểm tra xem một chuỗi có rỗng hay không Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes68 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes69_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No6
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes72 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes75 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes76 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes80 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 ['yes']0_______30_______1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes87 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes89 Đầu ra The string is empty. Bạn cũng có thể sử dụng hàm bool để kiểm tra xem một chuỗi có trống hay không sau khi xóa mọi khoảng trắng ở đầu hoặc cuối bằng phương thức dải Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes68 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes69_______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No9
The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes94 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty3 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes75 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes98 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes80 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 ['yes']0_______30_______1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes2 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes87 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes9 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes89 Đầu ra The string is empty. Phương pháp. sử dụng dải Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes12 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes13 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes15 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes16 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes18 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes19 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes21 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes25 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes32 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes34 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes16 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes37 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes41 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes48 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 Đầu ra string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty Phương pháp. Sử dụng phương thức __eq__ Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes50 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes51______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes15 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes54____0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes56 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes19 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes59 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes63 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes70 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes34 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes74 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes78 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes85 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 Đầu ra string, string1 = '', with no spaces is empty string, string1 = ' ', with no spaces is not empty Phương pháp. Sử dụng toán tử “and” + hàm strip() Python3The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes12 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes51______0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes15 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes54____0_______5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes18 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes19 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes51 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes98 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes70 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes63 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes34 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes7 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes54 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : No51 ['yes']15 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 ['yes']19 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 ['yes']0_______10_______28 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes5 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes1 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes24 ['yes']26 The zero length string without spaces is empty ? : Yes The zero length string with just spaces is empty ? : Yes26 Đầu ra string, string1 = '', with no spaces is empty string, string2 = ' ', with spaces is empty Phương pháp “bool” để kiểm tra xem một chuỗi có rỗng hay không có độ phức tạp về thời gian là O(1), vì nó chỉ đơn giản kiểm tra giá trị thực của chuỗi, đây là một phép toán thời gian không đổi. Không gian phụ cũng là O(1) vì nó chỉ yêu cầu một biến boolean duy nhất để lưu trữ giá trị thực của chuỗi |