Python学习日记(一)------------Using the Python Interpreter

1. Invoking the Interpreter

type 'python' command in DOS box.

To add the installation directory to user path, by typing set path = %path%;C:\python27. But if you restart the cmd window, you need to do this again.

2.Quiting the Interpreter

quit() or Control-Z on Windows, Control-D on Unix

3.Argument Passing

import sys

sys.argv[0]

4.Source Code Encoding

# -*- coding: encoding -*-

With that declaration, all characters in the source file will be treated as having the encoding encoding, and it will be possible to directly write Unicode string literals in the selected encoding.

5. The Interactive Startup File

When you use Python interactively, it is frequently handy to have some standard commands executed every time the interpreter is started. You can do this by setting an environment variable named PYTHONSTARTUP to the name of a file containing your start-up commands.

and if you want to use the start up file in a script, you must do this explicitly in the script

import os

filename = os.environ.get('PYTHONSTARTUP')

if filename and os.path.isfile(filename):

      execfile(filename)

 

6. The Customization Modules

Python provides two hooks to let you customize it: sitecustomize and usercustomize.

import site

site.getusersitepackages()

than create or modify file usercustomize.py int the directory.

 

ps:tty: 设备终端 Unix-style line ending ('\n'); Window line ending('\r\n')

.pyw, in this case , the console window that normally appears is suppressed.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值