《Beginning Python From Novice to Professional》学习笔记七:Statement

Beginning Python: From Novice to Professional 第二版 Gain a fundamental understanding of Python’s syntax and features with the second edition of Beginning Python, an up–to–date introduction and practical reference. Covering a wide array of Python–related programming topics, including addressing language internals, database integration, network programming, and web services, you’ll be guided by sound development principles. Ten accompanying projects will ensure you can get your hands dirty in no time. Updated to reflect the latest in Python programming paradigms and several of the most crucial features found in the forthcoming Python 3.0 (otherwise known as Python 3000), advanced topics, such as extending Python and packaging/distributing Python applications, are also covered. What you’ll learn * Become a proficient Python programmer by following along with a friendly, practical guide to the language’s key features. * Write code faster by learning how to take advantage of advanced features such as magic methods, exceptions, and abstraction. * Gain insight into modern Python programming paradigms including testing, documentation, packaging, and distribution. * Learn by following along with ten interesting projects, including a P2P file–sharing application, chat client, video game, remote text editor, and more. Complete, downloadable code is provided for each project! Who is this book for? Programmers, novice and otherwise, seeking a comprehensive introduction to the Python programming language. About the Apress Beginning Series The Beginning series from Apress is the right choice to get the information you need to land that crucial entry–level job. These books will teach you a standard and important technology from the ground up because they are explicitly designed to take you from “novice to professional.” You’ll start your journey by seeing what you need to know—but without needless theory and filler. You’ll build your skill set by learning how to put together real–world projects step by step. So whether your goal is your next career challenge or a new learning opportunity, the Beginning series from Apress will take you there—it is your trusted guide through unfamiliar territory! 立即下载
1.More about Print
print 'Age:', 42
---> Age: 42
注意以下语句的区别:
1, 2, 3
---> (1, 2, 3)
print 1, 2, 3
---> 1 2 3
print (1, 2, 3)
---> (1, 2, 3)

2.More about Import
import somemodule
from somemodule import somefunction
from somemodule import somefunction, anotherfunction, yetanotherfunction
from somemodule import *
import math as foobar
foobar.sqrt(4)
from math import sqrt as foobar
foobar(4)

3.赋值
Sequence Unpacking:
x, y, z = 1, 2, 3   #其实质是Tuple到Tuple的赋值
print x, y, z
---> 1 2 3

4.Blocks: The Joy of Indentation(伪代码pseudocode)
this is a line
this is another line:
    this is another block
    continuing the same block
    the last line of this block
phew, there we escaped the inner block
#由第二行的:号开始一段代码块,此段块均必须进行缩进

5.条件语句
在Python中,以下值如使用在Boolean中均被看作False:False、None、0、""、()、[]、{},其它全部被认为是True。
#As Python veteran Laura Creighton puts it, the distinction is really closer to something vs. nothing,
rather than true vs. false.


注意 True + False + 42   ---> 43
bool()可以转换为bool型
bool('I think') ---> True
bool(42)        ---> True
bool('')        ---> False
bool(0)         ---> False
注意  尽管bool([])==False,但[]!=False
#Nested Blocks:(一例以蔽之)


#比较也可以Chained:如 0 < age < 100.
#注意is比较和==比较的区别
x = y = [1, 2, 3]
z = [1, 2, 3]
x == y   ---> True
x == z   ---> True
x is y   ---> True
x is z   ---> False
x is not z ---> False
#is比较看是否相同而非是否相等(The Identity Operator),注意Python中的引用,x、y实际指向同一个List对象,所以x is y,
#而z指向另一个List对象(尽管有相同的值)


6.断言
assert 0 < age < 100                                    #当age不在此范围内时会引起异常
assert 0 < age < 100, 'The age must be realistic'       #后面字符串内的文字会作为异常说明

7.while循环


8.for循环


9.zip两个序列结对遍历

#zip()代码可以实现两个序列结对
zip(names, ages)   #若zip前后的List长度不同,它将会使用最短的结对
---> [('anne', 12), ('beth', 45), ('george', 32), ('damon', 102)]
#因此以下代码可实现等价功能
for name, age in zip(names, ages):
    print name, 'is', age, 'years old'

10.enumerate带下标遍历
首先介绍一下enumerate()函数,如何s是Iteratable的,则enumerate(s)会生成一个遍历对象
s=list('thy')   ---> ['t', 'h', 'y']
list(enumerate(s))
---> [(0, 't'), (1, 'h'), (2, 'y')]
for index, string in enumerate(strings):
    if 'xxx' in string:
        strings[index] = '[censored]'

11.sorted和reversed遍历
sorted([4, 3, 6, 8, 3])
---> [3, 3, 4, 6, 8]
sorted('Hello, world!')
---> [' ', '!', ',', 'H', 'd', 'e', 'l', 'l', 'l', 'o', 'o', 'r', 'w']
list(reversed('Hello, world!'))   #reversed生成的只是一个遍历对象,而非List
---> ['!', 'd', 'l', 'r', 'o', 'w', ' ', ',', 'o', 'l', 'l', 'e', 'H']
''.join(reversed('Hello, world!'))
---> '!dlrow ,olleH'

12.跳出循环
break, continue


13.循环中的else分句


14.List Comprehension—Slightly Loopy
#从其它List中生成List的方法
[x*x for x in range(10)]
---> [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
[x*x for x in range(10) if x % 3 == 0]
---> [0, 9, 36, 81]
[(x, y) for x in range(3) for y in range(3)]
---> [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]

16.del删除对象
x = ["Hello", "world"]
y = x
y[1] = "Python"   #注意y对赋值同时影响了x
x   --->['Hello', 'Python']
#但是接着
del x  #删除x却不会影响y,
      #The reason for this is that you delete only the name, not the list itself (the value).
       #In fact, there is no way to delete values in Python
y   ---> ['Hello', 'Python']

17.exec与eval
#exec运行String中的语句Python statements
from math import sqrt
scope = {}
exec 'sqrt = 1' in scope   #这样sqrt的影响被限制在scope中,否则下句的sqrt将被覆盖而无法运行
sqrt(4)   ---> 2.0
scope['sqrt']   ---> 1
#现在scope将会保存两个项,一项key为'__builtins__',包含了所有的内置函数和值。
#另一项则为'sqrt': 1。

#eval会计算String中的表达式Python expression并返回结果

eval(raw_input("Enter an arithmetic expression: "))
---> Enter an arithmetic expression: 6 + 18 * 2
---> 42

Beginning Python From Novice to Professional(3rd) 无水印pdf Beginning Python From Novice to Professional(3rd) 英文无水印pdf 第3版 pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除 立即下载

相关推荐

Apress.Beginning.Python.From.Novice.to.Professional.3rd.Edition.

亲测很好,很新,很全的Python 入门学习资料(转点奶粉钱)

python3入门教程 pdf_Python基础教程第3版(Beginning Python From Novice to Professional 3th) pdf...

Magnus Lie Hetland又更新他的 "Beginning Python From Novice to Professional"了,该书为第三版英文,基于Python3.5进行讲解,紧跟技术潮流。希望对Python爱好者有所帮助。这是Python最新的介绍和实际参考。涵盖广泛的Python相关编程主题,包括语言处理、数据库集成、网络编程和Web服务,遵循良好的开发原则。十个配套项目可以...

weixin_39640911的博客 621

Beginning Python From Novice to Professional(3rd) epub

Beginning Python From Novice to Professional(3rd) 英文epub 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除

Beginning Python: From Novice to Professional

Beginning Python: From Novice to Professional is the most comprehensive book on the Python ever written. Based on Practical Python, this newly revised book is both an introduction and practical refere

TopMVP 788

Beginning Python: From Novice to Professional, 2nd Edition

《Python基础教程, 第三版》的英文电子版。本书是经典的Python入门教程,层次鲜明、结构严谨、内容翔实,特别是后面几章,作者将前面讲述的内容应用到10个引人入胜的项目中,并以模板的形式介绍了项目的开发过程,手把手教授Python编程实践,让读者从项目中领略Python的真正魅力。

Vivado2023.2与Vitis协同开发:从Hello World到BOOT.BIN的完整流程解析

本文详细解析了使用Vivado 2023.2与Vitis协同开发ZYNQ/MPSoC平台的完整流程。从环境安装、硬件设计、软件编写、在线调试到生成独立的BOOT.BIN启动文件,手把手指导开发者完成从Hello World到系统固化的全步骤,并提供了常见问题的避坑指南,帮助初学者快速掌握软硬件协同开发的核心技能。

weixin_29197051的博客 178

《Beginning Python From Novice to Professional》学习笔记八:Abstraction

Laziness Is a Virtue --- Real programmers are lazy. Not lazy in a bad way, but in the sense that they don’t do unnecessary work. 1.创建函数 def fibs(num): result = [0, 1] for i in range(num-2)

thy专栏 851

不用写触发器!帆软填报报表自动记录创建/修改时间的终极方案

本文详细介绍了帆软填报报表中无需编写数据库触发器,即可自动记录数据创建时间和修改时间的终极方案。该方案利用帆软内置函数和单元格条件属性,在应用层实现日期自动生成,有效规避了触发器带来的权限、维护和部署难题,为数据填报提供了更轻量、灵活且易于维护的解决方案。

weixin_28040125的博客 365

《Beginning Python From Novice to Professional》学习笔记十二:__Magic__

1.属性访问class Rectangle: def __init__(self): self.width = 0 self.height = 0 def setSize(self, size): self.width, self.height = size #我的理解是自动组成Tuple def getS

thy专栏 970

百度网盘开放平台OAuth 2.0授权全流程解析

本文详细解析了百度网盘开放平台OAuth 2.0授权全流程,包括创建应用、获取凭证、授权码模式详解以及access_token的使用与刷新。通过实际案例和代码示例,帮助开发者快速掌握接口调用技巧,避免常见错误,确保安全高效地接入百度网盘API。

wind6的博客 1267

Material Studio 2024安装避坑指南:从证书配置到权限设置的完整解决方案

本文详细解析了Material Studio 2024的安装流程,从环境准备到权限优化的完整解决方案。针对证书配置、系统权限和计算服务等常见问题,提供了12个关键风险点的避坑指南,帮助科研工作者高效完成安装,提升材料模拟工作的效率。

moon9的博客 775

Beginning Python From Novice to Professional (3) - 列表操作

列表操作 list函数: >>> list('hello') ['h', 'e', 'l', 'l', 'o']改变列表: >>> x=[1,1,1] >>> x[1]=2 >>> x [1, 2, 1]删除元素: >>> names = ['wu','li','zhao','qian'] >>> del names[1] >>> names ['wu', 'zhao', 'qian']分

Marvin_wu 1203

仿真学习系列(三十八):Sigrity仿真之单端S参数提取

S 参数(Scattering Parameters)是高速信号分析中最基础也最常用的指标,能够全面表征走线、过孔、连接器等互连结构的高频行为。在 Sigrity PowerSI 中,Model Extraction 是最常用的 S 参数提取方式,适用于高速差分线、单端线、过孔、参考平面等各种拓扑结构。 本节将通过示例讲解如何在 PowerSI 中完成一次完整的 S 参数提取流程,包括:对象选择、端口设置、频率范围配置以及结果查看。掌握此方法后,即可对任意高速网络执行阻抗、插损、回损、串扰分析,为进一步的

案例文章,高速信号 838

Beginning Python From Novice to Professional (6) - 函数使用

函数使用 定义函数:

Marvin_wu 970

C#构建高精度预测模型:从数据预处理到模型部署的实战指南

【代码】C#构建高精度预测模型:从数据预处理到模型部署的实战指南。

墨夶的博客 1265

Python爬虫实战:全自动采集银行理财产品收益率数据

本文通过Playwright动态爬虫技术,成功实现了对银行理财产品收益率数据的实时采集,并通过 Pandas 数据清洗、SQLite 存储、调度自动化等模块,构建了一个可扩展的银行理财数据抓取系统。理财非儿戏,数据做决策。掌握银行收益信息是我们迈向理性投资的第一步。希望这套工具对你有所帮助!

2201_76125261的博客 1156

Beginning DB2: From Novice to Professional

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.youkuaiyun.com/topmvp - topmvpIBMs DB2 Express Edition is one of the most capable of the free database platforms available in todays market

TopMVP 663

芒果YOLOv11改进175:DCNv4卷积,全网首发纯Pytorch实现代码,无需cuda编译|即插即用,一键运行:高效可变形卷积网络:重新思考视觉应用的动态和稀疏算子

芒果YOLOv11改进:DCNv4卷积,全网首发纯Pytorch实现代码,无需cuda编译|即插即用,一键运行:高效可变形卷积网络:重新思考视觉应用的动态和稀疏算子

包括YOLOv5、YOLOv7、YOLOv8等模型改进 1298

《Beginning Python From Novice to Professional》学习笔记六:Dictionary

1.创建(注意Dictionary是没有顺序的) phonebook = {Alice: 2341, Beth: 9102, Cecil: 3258} 冒号之前为key,之后为value,key必须具有唯一性。 items = [(name, Gumby), (age, 42)] d = dict(items) ---> {age: 42, name:

thy专栏 973

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Beginning Game Development with Python and Pygame: From Novice to Professional

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.youkuaiyun.com/topmvp - topmvpLike music and movies, video games are rapidly becoming an integral part of our lives. Over the years, youve

TopMVP 1303

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

《Beginning Python From Novice to Professional》学习笔记三:List

1.删除元素 names = [thy, jlj, god, dog] del names[1] ---> [thy, god, dog] 2.片段赋值 names[1:]=list(thy) ---> [thy, t, h, y] names[2:2]=[] ---> [thy, t, y] 但要注意片段赋值的右值只能为List 3.a

thy专栏 772

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

《Beginning Python From Novice to Professional》学习笔记一:String

1.两个字符串放在一起会自动合并 "Lets say " "Hello, world!" --->Let/s say "Hello, world!" 但是两个字符串变量放在一起中间要加“+”号才会合并 2.str与repr str会将变量转化成某种用户能够理解的String方式,如 print str(10000L) --->10000 #str(object) -- Converts

thy专栏 997

《Beginning Python From Novice to Professional》学习笔记二:Sequence

1.下标从0开始,-1代表最后一个元素,-2为倒数第二个。 2.因为顺序化操作是内置的,所以形如 Hello[1] fourth = raw_input(Year: )[3] 均为合法输入 3.可以用*来重复List的值 如action = 3 * [go] --->([go] * 3也一样) [go, go, go] 而action = 3 * go --->(

thy专栏 776

《Beginning Python From Novice to Professional》学习笔记十:Exception

0.最重要的内置异常Exception:所有异常的基类AttributeError:属性引用或赋值异常IOError:试图读、写不存在的文件IndexError:使用Sequence中不存在的IndexKeyError:使用Mapping中不存在的KeyNameError:变量名未找到SyntaxError:语法错TypeError:在内置函数中使用错误的类型ValueError:类型对,但值不正

thy专栏 1176
上一篇: 《Beginning Python From Novice to Professional》学习笔记六:Dictionary
下一篇: 《Beginning Python From Novice to Professional》学习笔记八:Abstraction
thy38
博客等级 码龄19年 184粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值