字串練習

2022-08-26 00:21:28 字數 395 閱讀 6684

取得校園新聞的編號

str=''

print(str[-14:-5])

產生python文件的**

a1=""

a2=".html"

a3="turtle"

print(a1+a3+a2)

產生校園新聞的一系列新聞頁**

a1 = ''

a2='.html'

for i in range(1,220):

add=a1+str(i)+a2

print(add)

練習字串內建函式:strip,lstrip,rstrip,split,count

用函式得到校園新聞編號

s=''

print(s.rstrip('.html')[-9:])

字串練習

模擬tirm 方法 去除字串兩段的空格 思路 定義兩個變數 start end 分別從字串的兩段對字串進行逐個字元的判斷,當出現不是空格的字元時停止判斷,整個過程中保持 start end import com.ivan.util.systemutil public class practiseon...

字串練習

1,統計乙個字串中個字元的百分比 如輸入字串asdfs a 20 s 40 d 20 f 20 include include void percentage char str,int len if str str 判斷下乙個字元 int main int len 0 printf please i...

字串練習

字串練習 取得校園新聞的編號 num 14 5 print num 產生python文件的 com print com 產生校園新聞的一系列新聞頁 for i in range 20 print format i 練習字串內建函式 strip,lstrip,rstrip,split,count 用函...