2. Working with Strings

In this video | 在這條影片中
Basic Use of Strings
  • Strings must be enclosed by quotation marks
  • Strings can be enclosed by single quotation marks
  • A space in a string is treated as a letter
  • Strings (str) as a data type
  • 字符串必须被引号包围
  • 字符串亦可以被单引号包围
  • 字符串中的空格被当作字母处理
  • 资料类型为字符串 (str)
Joining Strings Together
  • Concatenate (+): joining two strings together
  • Use str() to convert a number into string for concatenation
  • Use len()to count the length of a string
  • Concatenate (+): 连接两组字符串
  • 使用 str() 把数字转换成字符串,后再连接
  • 使用 len() 数算字串的长度