python3.4 data type,python3.4data

來源:互聯網
上載者:User

python3.4 data type,python3.4data

#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);

  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.