日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

2.Strings and Console Output(字符串与输出)

發布時間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 2.Strings and Console Output(字符串与输出) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1、字符與字符串的賦值

brian = "Always look on the bright side of life!"

  

caesar = "Graham" praline = "John" viking = "Teresa"

  

fifth_letter = "MONTY"[4]print fifth_letter# 輸出的是Y,從0開始計數

2、字符串的一些函數以及數值轉字符串

pi = 3.14 print str(pi)#數值轉字符串

  

ministry = "The Ministry of Silly Walks"print len(ministry) # 長度 print ministry.upper() # 全部變成大寫 print ministry.lower() # 全部編程小寫

3、輸出補充

print "The value of pi is around " + str(3.14) print "Spam" + " and" + " eggs"

  

string_1 = "Camelot" string_2 = "place"print "Let's not go to %s. 'Tis a silly %s." % (string_1, string_2)name = raw_input("What is your name?") quest = raw_input("What is your quest?") color = raw_input("What is your favorite color?")print "Ah, so your name is %s, your quest is %s, " \ "and your favorite color is %s." % (name, quest, color)

4、例子

from datetime import datetimenow = datetime.now()print str(now.year) + "/" + str(now.month) + "/" + str(now.day)+" "+ str(now.hour) + ":" + str(now.minute) + ":" + str(now.second)

  

 

轉載于:https://www.cnblogs.com/hzhrestart/p/3340460.html

總結

以上是生活随笔為你收集整理的2.Strings and Console Output(字符串与输出)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。