Python学习记录(一)-- 最基础

1 运行python脚本(方法一)
    python hello.py

  运行python脚本(方法二)
    在脚本第一行加上 #!/usr/bin/env python
    修改脚本权限: chmod a+x hello.py
    执行 ./hello.py

2 注释格式
  # : #右边的代码会被忽略

3 字符串
  1) 使用单引号和双引号没有区别
    “hello, world” == 'hello.world' ==> 'hello,world'

  2) 数值转化为字符串
    "hello" + str(123)
    "hello" + repr(123)
    '123 ?? 反引号??

  3) input 和 raw_input
    input("what is your name?") # 输入 "yilia" 必须带有""
    raw_input("what is your name?") # 输入 yilia即可 无需带有""

4 原始字符串和unicode字符串
    原始字符串以 r 开头: print r'C:programfooar' '\'
    unicode字符串以u开头: u'hello, world!'

原文地址:https://www.cnblogs.com/songshu-yilia/p/5235623.html