1. 程式人生 > >Python3基礎語法 從入門到精通三

Python3基礎語法 從入門到精通三

# Python3 break continue pass 語句區別
for str in 'Python':     # break Example
   if str == 'h':
      break
   print ('Current str :',str);

print("break demo is end");

for str in 'Python':     # continue Example
   if str == 'h':
      continue
   print ('Current str :',str);

print("continue demo is end");

for str in 'Python':      # pass Example
    if str == 'h':
        pass
    print("Current str :",str)
print("pass demo is end");

#Python 字元函式
s = "HelloWorld";
print("轉換 s 中的小寫字母為大寫:",s.upper());
print("返回長度為 width 的字串,原字串 string 右對齊,前面填充:",s.zfill(12));