1
我正在寫一個Sublime2插件並打了一下。AttributeError:'str'對象沒有屬性'切片'
代碼是:
def run(self, edit):
self.edit = edit
self.view.window().show_input_panel("New Controller and View Path (ex: client_area/index)", "", self.trigger, None, None)
def trigger(self, user_entry):
formatted_entry = user_entry.encode('utf-8')
print formatted_entry.__class__
print formatted_entry
if formatted_entry.slice('/')[0] == '':
#some code
輸出是:
<type 'str'>
client_area/index
Traceback (most recent call last):
File "./PluginName.py", line 27, in trigger
AttributeError: 'str' object has no attribute 'slice'
它是如何我得到'str' object has no attribute 'slice'
? (Python版本爲2.6)
難道你不是指「分裂」? –
我認爲你通常會像''asdasd'[1:3]'切片一樣......我認爲bradley.ayers得到了它......我沒有想到它:( –