3

私は Sublime2 プラグインを書いていて、少し戦っています。

コードは次のとおりです。

  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)

4

2 に答える 2

7

slice文字列には Pythonのメソッドがありません- ということですsplitか (または、そのバリエーションなどrsplit)?

于 2012-11-27T00:39:21.077 に答える