python3.4 data type

2017-01-13 19:11:49来源:cnblogs.com作者:®Geovin Du Dream Park™人点击

第七城市
#coding=utf-8#Python 3.4  https://docs.python.org/3.4/library/#IDE:Eclipse +PyDev  Window10import atexitimport osimport sysimport timeimport winsoundimport codeimport codecsimport mathimport csvimport base64import reimport smtplibfrom email.mime.text import MIMETextfrom email.mime.multipart import MIMEMultipartfrom email.header import Header from email.mime.image import MIMEImagefrom email.mime.base import MIMEBase from email.utils import COMMASPACE, formatdate import emailimport os.path   import mimetypes  import configparserimport stringimport nltk import simhashimport uuidimport socketimport functoolsimport fnmatchimport timeimport datetimeimport calendarimport psycopg2from datetime import timedeltaimport randomimport unicodedatafrom decimal import * import MailSender #自定义类import choices #自定义类from jump import longprint("涂聚文,geovindu")  #中文显示必需文件编码格式utf-8#获取本机电脑名myname = socket.getfqdn(socket.gethostname(  ));#获取本机ipmyaddr = socket.gethostbyname(myname);print(myname);print(myaddr);#Data Typesprint ("hello word 你好,世界");print (sys.platform);print (2 ** 100);#输入try: userimput = input("输入的内容: ") #PyDevexcept NameError: passprint("你好:"+userimput);print(type(userimput));#类型nowTime=time.localtime();nowDate=datetime.datetime(nowTime[0],nowTime[1],nowTime[2]);datasd=["Acme",50,99.8,"2012-12-21",(2015,12,20)];productname,productshares,productprice,productdate,productdate2=datasd;print("产品名称:"+productname);print("产品数量:"+str(productshares));print("产品价格:"+str(productprice));print("产品日期:"+productdate); #datetime.datetime.strptimedate1=datetime.datetime(2015,12,20);print(type(nowTime)); #time.struct_timeprint(type(nowDate)); #atetime.datetimeprint(type(productdate2)); #tupleprint(type(productdate)); #strprint(date1);print(time.strftime("%Y-%m-%d %H:%M:%S",nowTime)); #%Y-%m-%d %H:%M:%S %fprint(nowDate);#print("time %" % nowDate);print(time.strptime(productdate,"%Y-%m-%d")); ##字符串转换成time类型 %Y-%m-%d %H:%M:%Sdate2=time.strptime(productdate,"%Y-%m-%d");print(nowDate.strftime("%Y-%m-%d")); ##time类型转换成字符串类型 %y-%m-%d %I:%M:%S %p  print(date2);print(type(date2));d = timedelta(microseconds=-1);print(d.days, d.seconds, d.microseconds); # -1 86399 999999year = timedelta(days=365);another_year = timedelta(weeks=40, days=84, hours=23,minutes=50, seconds=600);  # adds up to 365 daysprint(year.total_seconds()); #31536000.0print(year == another_year);dt = datetime.datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M");tt = dt.timetuple();'''2006    # year11      # month21      # day16      # hour30      # minute0       # second1       # weekday (0 = Monday)325     # number of days since 1st January-1      # dst - method tzinfo.dst() returned None'''for it in tt:       print (it);ic = dt.isocalendar();'''2006    # ISO year47      # ISO week2       # ISO weekday'''for ff in ic:    print(ff);print(calendar.setfirstweekday(calendar.SUNDAY)); #None#https://docs.python.org/3/library/index.htmld = Decimal(15.6);print(d+80);ra=random.randrange(0,12001,5); # Even integer from 0 to 1200 inclusive 从0至12000,5位数的随机数 11435print(ra);mood = choices.PDist([('happy', 0.3), ('neutral', 0.6), ('sad', 0.1)]) #随机选取字符串print(mood());rstr=random.choice(["geovindu","du","涂聚文","geovi"]); #随机选取字符串print(rstr);deck = 'ace two three four'.split();random.shuffle(deck);  # Shuffle a list 洗牌print(deck);du=int(2);print(du*20);du=long(200);print(du/20);du=float(2500.25);print(du-200);

  

#BitArray 布尔型数组所有的对象类型#Cubes OLAP 在线分析处理应用程序框架#Disco 分布式计算所用的mapreduce实现#Gdata Google数据协议实现#Hspy   Python HDF5文件格式实现#HDF5  快速I/O 操作所用文件格式  https://pypi.python.org/pypi/h5py#IPython 交互式开发环境(IDE)#lxml   用Python处理XML和HTML#matplotlib  #MPI4Py   消息解析接口(MPI)的并行计算实现#MPICH2   另一个MPI实现#numexpr  优化的数值表达式执行#Pandas 高效处理时间序列数据#PyTables 使用HDF5的层次化数据库  http://www.pytables.org/   pip install tables   http://www.pytables.org/usersguide/installation.html##SciPy   科学函数集合#Scikit-Learn 机器学习算法#Spyder Python IDE,具有语法检查,调试和检查功能#statsmodels 统计模型#SymPy 符号计算和数学  #Theano 数学表达式编译器#dateutil #pyparsing#libpng#pytz#freetype#cycler#pyqt#pygtk#wxpython#ffmpeg/avconv or mencoder#ImageMagick#Pillow#pkg-config#agg#import pyautogui  #PyAutoGUI https://pypi.python.org/pypi/PyAutoGUI#使用双连词生成随机文本sent=['In','the','beginning','god','created','the','heaven','and','the','earth','.'];mt=nltk.bigrams(sent);for mts in mt:    print(mts);

  http://www.h5py.org/

http://hdf5.net/

http://www.pytables.org/usersguide/installation.html

第七城市

最新文章

123

最新摄影

微信扫一扫

第七城市微信公众平台