Skip to main content
 首页 » 编程设计

python之从头开始切割字符串

2025年05月04日31tintown

<分区>

在 Python 中:

s = "Gwen Stefani" 
a = s[:0] 
b = s[0] 
 
print type(a) # str 
print type(b) # str 
print len(a)  # 0 
print len(b)  # 1 

我知道 s[:0] 是空的,但这也意味着从字符串的开头开始,所以我会认为:

s[:0] is the same as s[0]