需求1:列印 * 組成的分割線
用def定義函式print_line(),列印一行由 * 組成的分割線,
def print_line():
print("*" * 50)
print_line()
執行結果如下,
/home/parallels/desktop/04_函式/venv/bin/python /home/parallels/desktop/04_函式/hm_08_列印分割線.py
process finished with exit code 0
由 * 組成的分割線列印完成。
需求2:列印由任意字元組成的分割線
對程式進行改造,程式執行的時候把需要列印的字元,通過char引數傳入,程式更具有靈活性,改造後的程式如下,
def print_line(char):
print(char * 50)
print_line("-")
執行結果如下,
/home/parallels/desktop/04_函式/venv/bin/python /home/parallels/desktop/04_函式/hm_08_列印分割線.py
process finished with exit code 0
由 - 組成的分割線列印完成。
需求3:列印任意重複次數的分割線
通過times引數傳入執行的次數,改造後的函式如下,
def print_line(char,times):
print(char * times)
print_line("-",20)
執行結果如下,
/home/parallels/desktop/04_函式/venv/bin/python /home/parallels/desktop/04_函式/hm_08_列印分割線.py
process finished with exit code 0
控制台完成任意重複次數的列印。
需求4:可以列印5行任意字元且滿足需求3
通過while對函式進行改造,
def print_line(char,times):
print(char * times)
def print_lines():
row = 0
while row < 5:
print_line("-",50)
row += 1
print_lines()
執行結果如下:
/home/parallels/desktop/04_函式/venv/bin/python /home/parallels/desktop/04_函式/hm_08_列印分割線.py
process finished with exit code 0
需求5:通過形參傳入列印的字元和執行的次數
通過char和times傳入列印的字元和執行的次數,
def print_line(char,times):
print(char * times)
def print_lines(char,times):
row = 0
while row < 5:
print_line(char,times)
row += 1
print_lines("-",50)
執行結果如下,
/home/parallels/desktop/04_函式/venv/bin/python /home/parallels/desktop/04_函式/hm_08_列印分割線.py
process finished with exit code 0
列印字串完成。
print("hello world")
# 你說的對啊
listview的分割線
listview中每個item項之間都有分割線,設定android footerdividersenabled表示是否顯示分割線,此屬性預設為true。1.不顯示分割線只要在listview控制項中新增android footerdividersenabled false 即可。html view ...
Android 虛線分割線
drawable下新建乙個虛線的xml,dash line.xml 然後再布局引用就ok了。樓主,你的這個問題我遇到過,並且用另一種方式解決了。首先告訴你,listview的分割線不能設定為虛線,你也知道關於它的兩個屬性 android divider ffcc00 或者android divide...
補全cell分割線
if cell respondstoselector selector setseparatorinset if cell respondstoselector selector setpreservessuperviewlayoutmargins if cell respondstoselecto...