我在MacOSx 10.6.8上安装了python 2.7
python -v产生:
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so", 2);
import readline # dynamically loaded from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
Run Code Online (Sandbox Code Playgroud)
我他们跑:
$ virtualenv venv
Run Code Online (Sandbox Code Playgroud)
然后
$ . venv/bin/activate
Run Code Online (Sandbox Code Playgroud)
并做一个python -v
我得到:
Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
dlopen("/Users/nkhdev/venv/lib/python2.6/lib-dynload/readline.so", 2);
import readline # …Run Code Online (Sandbox Code Playgroud) 我有以下结构矢量:
(defstruct #^{:doc "Basic structure for book information."}
book :title :authors :price)
(def #^{:doc "The top ten Amazon best sellers on 16 Mar 2010."}
best-sellers
[(struct book
"The Big Short"
["Michael Lewis"]
15.09)
(struct book
"The Help"
["Kathryn Stockett"]
9.50)
(struct book
"Change Your Prain, Change Your Body"
["Daniel G. Amen M.D."]
14.29)
(struct book
"Food Rules"
["Michael Pollan"]
5.00)
(struct book
"Courage and Consequence"
["Karl Rove"]
16.50)
(struct book
"A Patriot's History of the United States"
["Larry Schweikart","Michael Allen"] …Run Code Online (Sandbox Code Playgroud) 可能重复:
Python:如何将字符串数组转换为数字数组?
我试图将字符串列表映射到Int,当我映射Int函数时,它将2位数字分成2个项目列表:
我有以下代码:
>>> MyList
['10', '5', '6', '7', '8', '9']
>>> MyList = [map(int,x) for x in MyList]
>>> MyList
[[1, 0], [5], [6], [7], [8], [9]]
Run Code Online (Sandbox Code Playgroud)
获取如下所示的列表的正确方法是什么:
[10, 5, 6, 7, 8, 9]
Run Code Online (Sandbox Code Playgroud)