抱歉,我还是个新手。试着学习python !! 我的代码 -
ScrollViewActivity.onCreate
当我尝试传递protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.scrollview);
_linearLayout = (LockedLinearLayout)findViewById(R.id.Container);
_scrollView = (LockedScrollView)findViewById(R.id.ScrollView);
_layoutInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
_linearLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
_scrollView.scrollTo(0, _scrollView.getScrollY() + (bottom - oldBottom ));
}
});
addExampleImage(10, _linearLayout);
}
- 时,给了我一个错误
列表索引必须是整数,而不是str
答案 0 :(得分:1)
我希望在我第一次学习时花更多时间了解标准库!
import collections
word_count = collections.Counter(['fizz', 'buzz'])
print(word_count['fizz'])
答案 1 :(得分:0)
def fizz_count(x):
count=0
for item in range(len(x)):
if x[item]=="fizz":
count=count+1
return count
或
def fizz_count(x):
count=0
for item in x:
if item=="fizz":
count=count+1
return count