• python小知识点


    1、配置python环境变量 path中添加pathon路径
    2、cmd执行python -m pydoc -p 1234   1234临时端口
    	访问localhost:1234/   可以查看python文档
    3、关于ideal上导入第三方module   
    	File---> Project Structure--->Platform Setting--->SDKS-->Python-->Packages--> 右边+号,输入相应别的module名称进行添加
    4、Elasticsearch  是一个开源的搜索引擎,建立在一个全文搜索引擎库 Apache Lucene™ 基础之上
    下载地址 :https://www.elastic.co/downloads/elasticsearch
    5、时间:print time.strftime("%Y-%m-%d %H:%M %p", time.localtime())  2014-11-14 17:54 PM
    python 获取当前时间
    
    import time   /
    
    timestamp = int(time.time())   当前时间毫秒数
    //将时间转换为  日期
    date = time.localtime(timestamp)
    time_format = '%Y-%m-%d %H:%M:%S' 定义日期格式
    print (time_format)  #打印时括号不能少
    return time.strftime(time_format, date)
    
    关于使用ideal安装第三方模块显示没有main方法是时:
    C:UsersAdministrator.IntelliJIdea2017.2configpluginspythonhelpers
    修改此路径(当前ideal安装位置)的packaging_tool.py 中的  do_install   un_install方法
    
    ip        = '127.0.0.1'
        port      = 3306
        db        = 'demo'
        user_name = 'root'
        user_pass = 'root'
        conn = pymysql.connect(host = ip, port = port, user = user_name, passwd = user_pass, db = db, charset = 'utf8')
        cursor = conn.cursor()
        sql = "select * from test_regex"
        cursor.execute(sql)
        rows = cursor.fetchall()
        i = 0
        for row in rows:
            id = row[0]
            url = row[1]
            regex = row[2]
            print(id)
            print(url)
            print(regex)
            i += 1
        print("finish")
    	
    	client = pymongo.MongoClient('localhost', 27017)
        #建立和数据库系统的连接,创建Connection时,指定host及port参数
        db = client.crawler
        db.authenticate("crawler_demo", "0305Wmph")
        #admin 数据库有帐号,连接-认证-切换库
        #db = client.crawler
        #连接数据库
    
        exchange_coll = db.www_as_exchange_com
        #for i in exchange_coll.find({'_id':'aaaaaaaaaaaaaaaaaaaa'}):
        for i in exchange_coll.find():
            print(i)
    

      

    人生没有彩排,每天都是现场直播!
  • 相关阅读:
    angular基础
    函数&闭包
    springboot + 拦截器 + 注解 实现自定义权限验证
    idea点击RUN启动报错: Broken configuration due to unavailable plugin or invalid configuration dat
    解决“指定的服务已经标记为删除”问题
    Mybatis中的XML中需要用到的转义符号整理
    springboot 2.0+ 自定义拦截器
    idea中lombok的使用
    springboot集成PageHelper,支持springboot2.0以上版本
    IDEA 修改JSP和后端数据后,页面刷新可以实时更新
  • 原文地址:https://www.cnblogs.com/northern-light/p/9708854.html
Copyright © 2020-2023  润新知