欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

7-5.11

发布时间:2023/12/10 编程问答 50 豆豆
生活随笔 收集整理的这篇文章主要介绍了 7-5.11 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

连接redis r = redis.Redis(host='118.24.3.40',password='HK139bc&*',db='13',decode_responses=True) r.set('lidandan','haha’) 发邮件: import yagmaill yagmall.SMTP(user  password=授权码  host) yagmall(to  cc  subject contens attachments=附件,绝对路径)  __main__: 在被导入文件中if __main__ == ’__main__’,执行文件,引入文件main中内容不会被执行 引入其他文件夹中的文件:文件夹添加到环境变量  写日志: import nnlog log = nnlog.Logger('test.log',level='error',backCount=5,when='S') log.debug('返回结果...')#一些调试信息,看变量值这些 log.info('info...') #一些提示信息 log.warning('waring')#出警告了 log.error('error...')#出错的时候打印的 操作mysql #!/usr/bin/python3 import pymysql # 打开数据库连接 db = pymysql.connect("localhost","testuser","test123","TESTDB" ) # 使用cursor() 方法创建一个游标对象 cursor cursor = db.cursor() # 使用 execute() 方法执行 SQL 查询 cursor.execute("SELECT VERSION()") # 使用 fetchone() 方法获取单条数据. data = cursor.fetchone() print ("Database version : %s " % data) # 关闭数据库连接 db.close()

转载于:https://www.cnblogs.com/dandan33/p/10879320.html

总结

以上是生活随笔为你收集整理的7-5.11的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。