笨办法学python的笔记

1.”“” python中三个引号连续使用,是长字符串输入的开端,例子是这样。

print """
Alright, so you said %r about liking me.
You live in %r.  Not sure where that is.
And you have a %r computer.  Nice.
""" % (likes, lives, computer).

2.转义字符表
转义字符 实现功能
\ Backslash ()
’ Single-quote (’)
" Double-quote (")
\a ASCII bell (BEL)
\b ASCII backspace (BS)
\f ASCII formfeed (FF)
\n ASCII linefeed (LF)
\N{name} Character named name in the Unicode database (Unicode only)
\r ASCII Carriage Return (CR)
\t ASCII Horizontal Tab (TAB)
\uxxxx Character with 16-bit hex value xxxx (Unicode only)
\Uxxxxxxxx Character with 32-bit hex value xxxxxxxx (Unicode only)
\v ASCII vertical tab (VT)
\ooo Character with octal value ooo
\xhh Character with hex value hh

  1. raw_input 和argv
    值得注意的是
    raw_input() 的里面可以添加提示,比如说 user_name(“what is the name of your pc?:”)二而argv是不可以的。
    其次,argv在命令行运行脚本的时候 地址+文件名+argv里需要获取的变量才可以运行。否则会提示
    ValueError: need more than 1 value to unpack

4.pydoc 并不能运行成功。而且不知道原因是什么。
5.

#this one is like your scripts with argv
def print_two(*args):
  arg1,arg2 = args
  print "arg1,%r,arg2: %r" % (arg1,arg2)
  
#ok, that *args is actually pointless,we can just do this
def print_two_again(arg1,arg2) :
 print "arg1: %r,arg2: %r" % (arg1,arg2)

#this just take one argument
def print_one(arg1):
 print"arg1:%r" % arg1

#this just take no arguments
def print_none():
 print"I 'v got nothing here."

print_none()
print_one(123)
print_two(123,123456)
print_two("zed","shaw")
print_two_again("Zed","Shaw")
#函数注意事项 
#1.函数定义是以def 开始的
#2.函数名称是以字符和下划线_组成的
#3.函数名称是要跟着括号的。
#4.括号里需要跟着参数,多个参数之间要用逗号隔开
#5.参数名称不能使用重复的 make sure that each argument is unique。
#6.变量名后面
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值