python3.4 data type

#coding=utf-8
#Python 3.4  https://docs.python.org/3.4/library/
#IDE:Eclipse +PyDev  Window10
import atexit
import os
import sys
import time
import winsound
import code
import codecs
import math
import csv
import base64
import re
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header
from email.mime.image import MIMEImage
from email.mime.base import MIMEBase
from email.utils import COMMASPACE, formatdate
import email
import os.path
import mimetypes
import configparser
import string
import nltk
import simhash
import uuid
import socket
import functools
import fnmatch
import time
import datetime
import calendar
import psycopg2
from datetime import timedelta
import random
import unicodedata
from decimal import *
import MailSender #自定义类
import choices #自定义类
from jump import long

print("涂聚文,geovindu")  #中文显示必需文件编码格式utf-8
#获取本机电脑名
myname = socket.getfqdn(socket.gethostname(  ));
#获取本机ip
myaddr = socket.gethostbyname(myname);
print(myname);
print(myaddr);

#Data Types

print ("hello word 你好,世界");
print (sys.platform);
print (2 ** 100);
#输入
try: userimput = input("输入的内容: ") #PyDev
except NameError: pass
print("你好:"+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.strptime
date1=datetime.datetime(2015,12,20);
print(type(nowTime)); #time.struct_time
print(type(nowDate)); #atetime.datetime
print(type(productdate2)); #tuple
print(type(productdate)); #str
print(date1);
print(time.strftime("%Y-%m-%d %H:%M:%S",nowTime)); #%Y-%m-%d %H:%M:%S %f
print(nowDate);
#print("time %" % nowDate);
print(time.strptime(productdate,"%Y-%m-%d")); ##字符串转换成time类型 %Y-%m-%d %H:%M:%S
date2=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 999999
year = timedelta(days=365);
another_year = timedelta(weeks=40, days=84, hours=23,minutes=50, seconds=600);  # adds up to 365 days
print(year.total_seconds()); #31536000.0
print(year == another_year);

dt = datetime.datetime.strptime("21/11/06 16:30", "%d/%m/%y %H:%M");
tt = dt.timetuple();
‘‘‘
2006    # year
11      # month
21      # day
16      # hour
30      # minute
0       # second
1       # 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 year
47      # ISO week
2       # ISO weekday
‘‘‘
for ff in ic:
    print(ff);

print(calendar.setfirstweekday(calendar.SUNDAY)); #None

#https://docs.python.org/3/library/index.html

d = Decimal(15.6);
print(d+80);
ra=random.randrange(0,12001,5); # Even integer from 0 to 1200 inclusive 从0至12000,5位数的随机数 11435
print(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);

  

时间: 2024-07-30 13:20:31

python3.4 data type的相关文章

PHP 笔记一(systax/variables/echo/print/Data Type)

PHP stands for "Hypertext Preprocessor" ,it is a server scripting language. What Can PHP Do? PHP can generate dynamic page content PHP can create, open, read, write, delete, and close files on the server PHP can collect form data PHP can send an

Linux C double linked for any data type

/************************************************************************** * Linux C double linked for any data type * 声明: * 提供一种双链接口,可以保存保存任何类型的数据. * * 2015-12-25 晴 深圳 南山平山村 曾剑锋 **********************************************************************

诡异错误二:TypeError: data type not understood

如何使用Python产生一个数组,数组的长度为1024,数组的元素全为0? 很简单啊, 使用zeros(1024) 即可实现! 如何产生一个2×1024的全0矩阵呢?是否是zeros(2,1024) ? 若是上述这种写法就会出现 TypeError: data type not understood  这种错误: 正确的写法是 zeros((2,1024)),python的二维数据表示要用二层括号来进行表示. 三维数据是否使用三层括号?试一试,果然可以正确输出!试猜一猜, 下述三层括号中的数字分

【Agile Pair Coding】Data Type Mapping

介绍 今天下午用了1个小时左右,和同事Agile Pair Coding敏捷开发了一把,感觉挺爽的. Agile Pair Coding给我们带来的直接好处是:相互不浪费时间,高效:idea很快达成共识,不纠结于无谓的讨论:idea立马coding,不沉迷于头脑风暴:代码更严谨:重构概率大:加深基情:相互学习,相互欣赏,相互指正:避免无知,避免自我感觉良好...... 代码主要实现:从所有类型文件中,得到所有NE类型下的所有Object类型下的所有属性的数据类型. 当然,本文只是一个短时间内的D

JAVA 1.2(原生数据类型 Primitive Data Type)

1. Java的数据类型分为2类 >> 原生数据类型(primitive data type) >> 引用数据类型(reference data type) 3. 常量和变量 常量: 所谓常量,就是值不会变化的量: 变量,就是值可以变化的量. 4. 如何定义和使用变量? int a; //变量的申明 a = 10; // 变量的初始化 int b = 20; // 变量的申明和初始化 注意事项: 如果没有初始化会出以下结果: 在Java中的== 和= 的区别: =  代表的是赋值操

Value too large for defined data type的解决方法之一

折腾了两三天,尝试了网上各种办法最后终于把这个给解决了. 进入正题 之前用的是arm-2009的编译链,在不是共享文件夹下编译的话一切都正常,可以生成想要的目标文件,一旦放入/mnt/hgfs/xxx/(xxx表示自己创建的共享文件夹名称)然后进行make指令后就会出现Value too large for defined data type无奈之下改安装arm-2012的交叉工具链,得以解决.可以保留之前安装的arm-2009不影响后者工作,但要记得进入cd ~vi .bashrc中的末行添加

7.1The ISO SQL Data Type

In this section we introduce the data types defined in the SQL standard. We start by defining what constitutes a vailed identifer in SQL. 7.1.1  SQL Identifiers SQL identifiers are identify objects in the database, such as table names, views names, a

ADT (Abstract Data Type)

抽象数据类型 ADT (Abstract Data Type) 是一个实现包括储存数据元素的存储结构以及实现基本操作的算法.在这个数据抽象思想中,数据类型的定义和它的实现是分开的,这在软件设计中是一个重要的概念.这使得只研究和使用它的结构而不用考虑它的实现细节成为可能. ADT包括数据数据元素,数据关系以及相关的操作. 即ADT { 数据对象:(数据元素集合) 数据关系:(数据关系二元组结合) 基本操作:(操作函数的罗列) }

include pointers as a primitive data type

Computer Science An Overview _J. Glenn Brookshear _11th Edition Many modern programming languages include pointers as a primitive data type. That is, they allow the declaration, allocation, and manipulation of pointers in ways reminiscent of integers