zoukankan      html  css  js  c++  java
  • python学习第一天

          在看过几个python脚本后,拼拼凑凑的写过几个脚本,没有系统的了解过语法终究降低写脚本与调试脚本的效率,今天终于静下心来开始学习python基础:

    字符串:

    单引号字符串与转义引号:’let’s go’

    拼接字符串:”hello,” + “world!” 或者分别赋值xy,然后x + y拼接

    字符串表示:str(“hello,world!”)强制转换字符串,输出hello,world!;repr(“hello,world!”)输出’hello.world!’

    Input与raw_input比较:name = input(‘what is your name?’)与name = raw_input(‘what is your name?’)  print “hello” + name + “!” 

    相比raw_input函数input用户必须输入带引号的名字才能正常输出,否则报语法错误。

    长字符串、原始字符串、unicode字符串

    长字符用三引号括起来’’’;

    原始字符串以r开头:print r ‘D: xiaofanDownloads’ 这样不会转义 ;不能在原始字符串末尾输入反斜线(示例如下);

     

    Unicode字符串:unicode字符串存储为16位的unicode字符,这样能表达更多的字符集,包括世界上大多数语言的特殊字符,而python中普通字符串内部以8位ASCII码存储。

    U ‘hello,world!’

  • 相关阅读:
    Reverse Linked List
    Sqrt(x)
    Convert Sorted Array to Binary Search Tree
    Remove Linked List Elements
    Happy Number
    Length of Last Word
    Pow(x, n)
    Rotate Image
    Permutations
    Integer to Roman
  • 原文地址:https://www.cnblogs.com/junlinqunxia/p/7473776.html
Copyright © 2011-2022 走看看