|
|
|
|
|
|
吴裕雄 python 神经网络——TensorFlow 卷积神经网络手写数字图片识别
摘要:import os import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data INPUT_NODE = 784 OUTPUT_NODE = 10 LAYER1_NODE = 500 def get_weight_variable(shape, regularizer): wei...
阅读全文
吴裕雄--天生自然 python开发学习:在Cenos 7 系统上安装配置python3.6.5
摘要:安装相关依赖包。 在终端下输入命令:sudo yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 使用wget从官网下载安装包。在终端下输入命令: ...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:MongoDB
摘要:import pymongo myclient = pymongo.MongoClient("mongodb://localhost:27017/") mydb = myclient["runoobdb"] import pymongo myclient = pymongo.MongoClient('mongodb://localhost:27017/') dblist = my...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:日期和时间
摘要:import time; # 引入time模块 ticks = time.time() print ("当前时间戳为:", ticks) import time localtime = time.localtime(time.time()) print ("本地时间为 :", localtime) import time localtime = time.asctime( tim...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:JSON 数据解析
摘要:import json # Python 字典类型转换为 JSON 对象 data = { 'no' : 1, 'name' : 'Runoob', 'url' : 'http://www.runoob.com' } json_str = json.dumps(data) print ("Python 原始数据:", repr(data)) print ("JSO...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:XML 解析
摘要:War, Thriller DVD 2003 PG 10 Talk about a US-Japan war Anime, Science Fiction DVD 1989 R 8 A schientific fiction Anime, Action DVD 4 PG 10 ...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:多线程
摘要:import _thread import time # 为线程定义一个函数 def print_time( threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print ("%s: %s" % ( threadName, time.ctime(...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:SMTP发送邮件
摘要:import smtplib smtpObj = smtplib.SMTP( [host [, port [, local_hostname]]] ) SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options] import smtplib from email.mime.text import MIMETe...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:网络编程
摘要:# 导入 socket、sys 模块 import socket import sys # 创建 socket 对象 serversocket = socket.socket( socket.AF_INET, socket.SOCK_STREAM) # 获取本地主机名 host = socket.gethostname() port = 9999 # 绑定端口号...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:数据库连接 - PyMySQL 驱动
摘要:import pymysql # 打开数据库连接 db = pymysql.connect("localhost","testuser","test123","TESTDB" ) # 使用 cursor() 方法创建一个游标对象 cursor cursor = db.cursor() # 使用 execute() 方法执行 SQL 查询 cursor.execute("SELEC...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:MySQL - mysql-connector 驱动
摘要:import mysql.connector mydb = mysql.connector.connect( host="localhost", # 数据库主机地址 user="yourusername", # 数据库用户名 passwd="yourpassword" # 数据库密码 ) print(mydb) import mysql.connec...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:CGI编程
摘要:AllowOverride None Options +ExecCGI Order allow,deny Allow from all print ("Content-type:text/html") print () # 空行,告诉服务器结束头部 print ('') print ('') print ('...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:正则表达式
摘要:import re print(re.match('www', 'www.runoob.com').span()) # 在起始位置匹配 print(re.match('com', 'www.runoob.com')) # 不在起始位置匹配 import re line = "Cats are smarter than dogs" # .* 表示任意匹配除换行符(\n、\...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:面向对象
摘要:class MyClass: """一个简单的类实例""" i = 12345 def f(self): return 'hello world' # 实例化类 x = MyClass() # 访问类的属性和方法 print("MyClass 类的属性 i 为:", x.i) print("MyClass 类的方法 f 输出为:", x.f()) ...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:OS 文件/目录方法
摘要:import os, sys # 假定 /tmp/foo.txt 文件存在,并有读写权限 ret = os.access("/tmp/foo.txt", os.F_OK) print ("F_OK - 返回值 %s"% ret) ret = os.access("/tmp/foo.txt", os.R_OK) print ("R_OK - 返回值 %s"% ret) ret = os.a...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:File(文件) 方法
摘要:# 打开文件 fo = open("runoob.txt", "wb") print("文件名为: ", fo.name) # 关闭文件 fo.close() # 打开文件 fo = open("runoob.txt", "wb") print ("文件名为: ", fo.name) # 刷新缓冲区 fo.flush() # 关闭文件 fo.close() # 打开文件 fo = ...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:输入和输出
摘要:str = input("请输入:"); print ("你输入的内容是: ", str) # 打开一个文件 f = open("/tmp/foo.txt", "w") f.write( "Python 是一个非常好的语言。\n是的,的确非常好!!\n" ) # 关闭打开的文件 f.close() # 打开一个文件 f = open("/tmp/foo.txt", "r") str...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:函数
摘要:def 函数名(参数列表): 函数体 # 计算面积函数 def area(width, height): return width * height def print_welcome(name): print("Welcome", name) print_welcome("Runoob") w = 4 h = 5 print("width =", w, " ...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:迭代器与生成器
摘要:list=[1,2,3,4] it = iter(list) # 创建迭代器对象 for x in it: print (x, end=" ") import sys # 引入 sys 模块 list=[1,2,3,4] it = iter(list) # 创建迭代器对象 while True: try: print (ne...
阅读全文
吴裕雄--天生自然 PYTHON3开发学习:循环语句
摘要:n = 100 sum = 0 counter = 1 while counter in : else: sites = ["Baidu", "Google","Runoob","Taobao"] for site in sites: if site == "Runoob": print("菜鸟教程!") break ...
阅读全文
|
|