嗨我希望它打印范围内的所有数字,但我只收回输入数字。不知道为什么。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:fitsSystemWindows="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="@dimen/layout_width"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:background="@drawable/header" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="32sp"
android:padding="5dp"
android:gravity="center_horizontal"
android:text="A line of text"
android:background="@drawable/body" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/footer_height"
android:background="@drawable/footer" />
</LinearLayout>
<Space
android:layout_width="match_parent"
android:layout_height="10dp" />
<LinearLayout
android:layout_width="@dimen/layout_width"
android:layout_height="wrap_content"
android:orientation="vertical" >
<View
android:layout_width="match_parent"
android:layout_height="@dimen/header_height"
android:background="@drawable/header" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="32sp"
android:padding="5dp"
android:gravity="center_horizontal"
android:text="A line of text\nAnother line of text"
android:background="@drawable/body" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/footer_height"
android:background="@drawable/footer" />
</LinearLayout>
</LinearLayout>
答案 0 :(得分:0)
这是因为a > b
时a
打印的数字从b+1
打印到b
而不是我认为你真正想要的数字(a+1
到>>> a = int(input())
0
>>> b = int(input())
5
>>> if a > b:
... for number in range(b, a+1):
... print(number)
... else:
... for number in range(a, b+1):
... print(number)
...
0
1
2
3
4
5
)。颠倒你的状况应该让它发挥作用。
>>> a = int(input())
10
>>> b = int(input())
20
>>> for number in range(min(a, b), max(a, b) + 1):
... print(number)
...
10
11
12
13
14
15
16
17
18
19
var Overview = (function(){
HubStarter.wait("Overview");
var exports = {};
exports.Format = function(value){
//some code
};
return exports;
})();
range的文档也可能让您感兴趣。