易截截图软件、单文件、免安装、纯绿色、仅160KB

Python 3.x (1):入门

 
1 你好
#打开新窗口,输入:
#! /usr/bin/python
# -*- coding: utf8 -*- 
s1=input("Input your name:")
print("你好,%s" % s1)
'''
知识点:
    * input("某字符串")函数:显示"某字符串",并等待用户输入.
    * print()函数:如何打印.
    * 如何应用中文
    * 如何用多行注释
'''    
2 字符串和数字
但有趣的是,在javascript里我们会理想当然的将字符串和数字连接,因为是动态语言嘛.但在Python里有点诡异,如下:
#! /usr/bin/python
a=2
b="test"
c=a+b
运行这行程序会出错,提示你字符串和数字不能连接,于是只好用内置函数进行转换
#! /usr/bin/python
#运行这行程序会出错,提示你字符串和数字不能连接,于是只好用内置函数进行转换
a=2
b="test"
c=str(a)+b
d="1111"
e=a+int(d)
#How to print multiply values
print ("c is %s,e is %i" % (c,e))
'''
知识点:
    * 用int和str函数将字符串和数字进行转换
    * 打印以#开头,而不是习惯的//
    * 打印多个参数的方式
    '''
3 列表
#! /usr/bin/python
# -*- coding: utf8 -*-
#列表类似Javascript的数组,方便易用
#定义元组
word=['a','b','c','d','e','f','g']
#如何通过索引访问元组里的元素
a=word[2]
print ("a is: "+a)
b=word[1:3]
print ("b is: ")
print (b) # index 1 and 2 elements of word.
c=word[:2]
print ("c is: ")
print (c) # index 0 and 1 elements of word.
d=word[0:]
print ("d is: ")
print (d) # All elements of word.
#元组可以合并
e=word[:2]+word[2:]
print ("e is: ")
print (e) # All elements of word.
f=word[-1]
print ("f is: ")
print (


相关文档:

python PIL 批量处理处理图片

客户给一堆图片要传到后台,图片太大了,上百张图用photoshop改太慢,就想到用python写个简单的批处理。功能简单就是把原图按比例缩小,代码更简单 20多行。
# -*- coding: cp936 -*-
import Image
import glob, os
#图片批处理
def timage():
for files in glob.glob('D:\\1\\*.JPG'):
filepath,filena ......

Python笔记(9)

Python中的文件操作以及输入输出
我们可以分别使用raw_input和print语句来完成这些功能。对于输出,你也可以使用多种多样的str(字符串)类。例如,你能够使用rjust方法来得到一个按一定宽度右对齐的字符串。利用help(str)获得更多详情。
 
 
另一个常用的输入/输出类型是处理文件。创建、读和写文件的能力是 ......

Python IDE and GUI Framework for Windows

Pythonwin - Python IDE and GUI Framework for Windows.
Copyright 1994-2006 Mark Hammond
Python is Copyright (c) 2000-2008 ActiveState Software Inc.
Copyright (c) 2001-2008 Python Software Foundation.
All Rights Reserved.
Copyright (c) 2000 BeOpen.com.
All Rights Reserved.
Copyright (c) 1995-20 ......

很好的c++和Python混合编程文章

http://www.cppblog.com/jacky2019/archive/2007/05/17/24269.html
c++中嵌入python入门1
本人是用vc2003+python2.5学习的,其它的也应该差不了多少
0. 坏境设置
把python的include/libs目录分别加到vc的include/lib directories中去。另外,由于python没有提供debug lib,体地说,就是没有提供python25_d.lib了。你可 ......

python两个dict相加


>>> a = {'1':'2'}
>>> b = {'3':'4'}
>>> a+b
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
>>> a.update(b)
>>> a
{'1': '2', '3': '4'} ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号