python 学习源码练习(1)
#编译方式,python3 文件名
#!/usr/bin/python3
#print('hello world')
mystring = 'hello world'
print (mystring)
#测试输入
#!\usr\bin\python3
num = input('Please enter an num :')
print ("now Doubling your num %d" % (int(num)*2))
#字符串和切片
#!/usr/bin/python3
pystr = 'Python'
iscool = 'is cool'
print ('pystr[0] is %s.' % pystr[0])
print ('pystr[2:5] is %s'% pystr[2:5])
#!/usr/bin/python3
#if test
count = 1
if count > 1:
print ("test 1")
elif count == 1 :
print ("test 2")
#while loop test
while count < 3:
print("now count = %d" % count)
count += 1
#for loop test
print("I like to use internet for:")
for item in ['e-mail', 'net-surfing', 'homework']:
print(item,)
print()
#range test
for eachNum in [0,1,2]:
print(eachNum)
print('*'*4)
for eachNum in range(3):
print(eachNum)
print('test for string','*'*4)
foo = 'abs'
for s in foo:
print(s)
print('test of range and len')
for i in range(len(foo)):
print (foo[i],'%d'%i)
squared = [x**2 for x in range(4)]
for i in squared:
print(i)
#function test
def addMe2Me(x):
'apply + operation to argument'
return (x+x)
print(addMe2Me([2,'4']))
#default function param test
#!/usr/bin/python3
def foo(debug=True):
if debug:
print('cur in debug mode')
else:
print('cur in realse mode')
print('done')
foo(False)
#class test
#!/usr/bin/python3
class Myfoo(object):
version = 0.1
def __init__(self,nm='John Doe'):
self.name = nm
print('created a class instance for',nm)
print('this is a ','test')
def showname(self):
print('your name is ', self.name)
def showverison(self):
print( self.version)
foo = Myfoo()
python 学习源码练习(1)的更多相关文章
- python 学习源码练习(2)——简单文件读取
#文件创建 #!/usr/bin/python3 'makeTextFile.py--create text file' import os ls = os.linesep #get filename ...
- 《python解释器源码剖析》第0章--python的架构与编译python
本系列是以陈儒先生的<python源码剖析>为学习素材,所记录的学习内容.不同的是陈儒先生的<python源码剖析>所剖析的是python2.5,本系列对应的是python3. ...
- NLP大赛冠军总结:300万知乎多标签文本分类任务(附深度学习源码)
NLP大赛冠军总结:300万知乎多标签文本分类任务(附深度学习源码) 七月,酷暑难耐,认识的几位同学参加知乎看山杯,均取得不错的排名.当时天池AI医疗大赛初赛结束,官方正在为复赛进行平台调 ...
- 框架源码系列五:学习源码的方法(学习源码的目的、 学习源码的方法、Eclipse里面查看源码的常用快捷键和方法)
一. 学习源码的目的 1. 为了扩展和调优:掌握框架的工作流程和原理 2. 为了提升自己的编程技能:学习他人的设计思想.编程技巧 二. 学习源码的方法 方法一: 1)掌握研究的对象和研究对象的核心概念 ...
- 【转】python:让源码更安全之将py编译成so
python:让源码更安全之将py编译成so 应用场景 Python是一种面向对象的解释型计算机程序设计语言,具有丰富和强大的库,使用其开发产品快速高效. python的解释特性是将py编译为独有的二 ...
- springboot学习源码
springbootTest 学习源码链接 启动前,需要创建数据库表,修改自己的链接配置 create database test01; use test01; CREATE TABLE catego ...
- python 协程库gevent学习--源码学习(一)
总算还是要来梳理一下这几天深入研究之后学习到的东西了. 这几天一直在看以前跟jd对接的项目写的那个gevent代码.为了查错,基本上深入浅出了一次gevent几个重要部件的实现和其工作的原理. 这里用 ...
- python SimpleHTTPServer源码学习
SimpleHTTPServer.SimpleHTTPRequestHandler继承了BaseHTTPServer.BaseHTTPRequestHandler. 源码中主要实现了BaseHTTPS ...
- 通过阅读python subprocess源码尝试实现非阻塞读取stdout以及非阻塞wait
http://blog.chinaunix.net/uid-23504396-id-4661783.html 执行subprocess的时候,执行不是问题最麻烦的是获取进程执行后的回显来确认是否正确执 ...
随机推荐
- mysql数据表最高速迁移,mysql的存储引擎为:myisam
本文链接:http://blog.csdn.net/u010670689/article/details/41346689 需求: 开发产品过程中,有个项目分支,数据库须要带数据拷贝,可是表的数据非常 ...
- css怎样让背景充满整个屏幕
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- HBase:Shell
HBase shell commands As told in HBase introduction, HBase provides Extensible jruby-based (JIRB) she ...
- Hadoop:Rack Awareness
副本的放置对HDFS可靠性和性能至关重要. 优化副本放置HDFS有别于其他大多数分布式文件系统. 这是一个功能,需要大量的调优和经验. 基于机架感知(rack awareness)的副本放置策略的目的 ...
- IDEA使用--字体、编码和基本设置
IDEA这么高端的工具之前只是断断续续使用了一下,因为项目的开发都是在eclipse上,每次学习IDEA的使用都得上网搜索半天,今天自己整理一下,方便以后查阅. IDEA版本15.0.4 字体 界面字 ...
- idea的mybatis的xml文件总是报警告SQL dialect is not configured
警告: No data sources are configured to run this SQL and provide advanced code assistance. Disable thi ...
- [译文]React v16(新特性)
[译文]React v16(新特性) 查看原文内容 我们很高兴的宣布React v16.0发布了! 这个版本有很多长期被使用者期待的功能,包括: fragments (返回片段类型) error bo ...
- iOS 用户密码 数字字母特殊符号设置 判断
//直接调用这个方法就行 -(int)checkIsHaveNumAndLetter:(NSString*)password{ //数字条件 NSRegularExpression *tNumRegu ...
- SpringJDBC的JdbcTemplate在MySQL5.7下不支持子查询的问题
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [ SELECT ...
- Linux第七节随笔-中 /date / ln /
4.date link 作用:显示或设定系统的日期与时间 参数: -d<字符串> 显示字符串所指的日期与时间.字符串前后必须加上双引号. -s<字符串> 根据字符串来设置日期与 ...